Class: Fastlane::Actions::UpdateIcloudContainerIdentifiersAction

Inherits:
Fastlane::Action
  • Object
show all
Defined in:
lib/fastlane/actions/update_icloud_container_identifiers.rb

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, details, return_value, sh, step_text

Class Method Details

.authorsObject



71
72
73
# File 'lib/fastlane/actions/update_icloud_container_identifiers.rb', line 71

def self.authors
  ["JamesKuang"]
end

.available_optionsObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/fastlane/actions/update_icloud_container_identifiers.rb', line 48

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :entitlements_file,
                                 env_name: "FL_UPDATE_ICLOUD_CONTAINER_IDENTIFIERS_ENTITLEMENTS_FILE_PATH",
                                 description: "The path to the entitlement file which contains the iCloud container identifiers",
                                 verify_block: proc do |value|
                                   UI.user_error!("Please pass a path to an entitlements file. ") unless value.include? ".entitlements"
                                   UI.user_error!("Could not find entitlements file") if !File.exist?(value) and !Helper.is_test?
                                 end),
    FastlaneCore::ConfigItem.new(key: :icloud_container_identifiers,
                                 env_name: "FL_UPDATE_ICLOUD_CONTAINER_IDENTIFIERS_IDENTIFIERS",
                                 description: "An Array of unique identifiers for the iCloud containers. Eg. ['iCloud.com.test.testapp']",
                                 is_string: false,
                                 verify_block: proc do |value|
                                   UI.user_error!("The parameter icloud_container_identifiers needs to be an Array.") unless value.kind_of? Array
                                 end)
  ]
end

.descriptionObject



44
45
46
# File 'lib/fastlane/actions/update_icloud_container_identifiers.rb', line 44

def self.description
  "This action changes the iCloud container identifiers in the entitlements file"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/fastlane/actions/update_icloud_container_identifiers.rb', line 75

def self.is_supported?(platform)
  platform == :ios
end

.outputObject



67
68
69
# File 'lib/fastlane/actions/update_icloud_container_identifiers.rb', line 67

def self.output
  ['UPDATE_ICLOUD_CONTAINER_IDENTIFIERS', 'The new iCloud Container Identifiers']
end

.run(params) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fastlane/actions/update_icloud_container_identifiers.rb', line 10

def self.run(params)
  entitlements_file = params[:entitlements_file]
  UI.message "Entitlements File: #{entitlements_file}"

  # parse entitlements
  result = Plist.parse_xml(entitlements_file)
  UI.error "Entitlements file at '#{entitlements_file}' cannot be parsed." unless result

  # get iCloud container field
  icloud_container_key = 'com.apple.developer.icloud-container-identifiers'
  icloud_container_value = result[icloud_container_key]
  UI.error "No existing iCloud container field specified. Please specify an iCloud container in the entitlements file." unless icloud_container_value

  # get uniquity container field
  ubiquity_container_key = 'com.apple.developer.ubiquity-container-identifiers'
  ubiquity_container_value = result[ubiquity_container_key]
  UI.error "No existing ubiquity container field specified. Please specify an ubiquity container in the entitlements file." unless ubiquity_container_value

  # set iCloud container identifiers
  result[icloud_container_key] = params[:icloud_container_identifiers]
  result[ubiquity_container_key] = params[:icloud_container_identifiers]

  # save entitlements file
  result.save_plist(entitlements_file)

  UI.message "Old iCloud Container Identifiers: #{icloud_container_value}"
  UI.message "Old Ubiquity Container Identifiers: #{ubiquity_container_value}"

  UI.success "New iCloud Container Identifiers set: #{result[icloud_container_key]}"
  UI.success "New Ubiquity Container Identifiers set: #{result[ubiquity_container_key]}"

  Actions.lane_context[SharedValues::UPDATE_ICLOUD_CONTAINER_IDENTIFIERS] = result[icloud_container_key]
end