Class: Fastlane::Actions::UpdateIcloudContainerIdentifiersAction

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

Constant Summary

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES, Fastlane::Action::RETURN_TYPES

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, deprecated_notes, lane_context, method_missing, other_action, return_type, return_value, sample_return_value, shell_out_should_use_bundle_exec?, step_text

Class Method Details

.authorsObject


77
78
79
# File 'fastlane/lib/fastlane/actions/update_icloud_container_identifiers.rb', line 77

def self.authors
  ["JamesKuang"]
end

.available_optionsObject


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'fastlane/lib/fastlane/actions/update_icloud_container_identifiers.rb', line 52

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) && !Helper.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

.categoryObject


94
95
96
# File 'fastlane/lib/fastlane/actions/update_icloud_container_identifiers.rb', line 94

def self.category
  :misc
end

.descriptionObject


44
45
46
# File 'fastlane/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

.detailsObject


48
49
50
# File 'fastlane/lib/fastlane/actions/update_icloud_container_identifiers.rb', line 48

def self.details
  "Updates the iCloud Container Identifiers in the given Entitlements file, so you can use different iCloud containers for different builds like Adhoc, App Store, etc."
end

.example_codeObject


85
86
87
88
89
90
91
92
# File 'fastlane/lib/fastlane/actions/update_icloud_container_identifiers.rb', line 85

def self.example_code
  [
    'update_icloud_container_identifiers(
      entitlements_file: "/path/to/entitlements_file.entitlements",
      icloud_container_identifiers: ["iCloud.com.companyname.appname"]
    )'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:


81
82
83
# File 'fastlane/lib/fastlane/actions/update_icloud_container_identifiers.rb', line 81

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

.outputObject


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

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 'fastlane/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