Class: Fastlane::Actions::UpdateAppAssociatedDomainsAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/update_app_associated_domains/actions/update_app_associated_domains_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



36
37
38
# File 'lib/fastlane/plugin/update_app_associated_domains/actions/update_app_associated_domains_action.rb', line 36

def self.authors
  ["Nicolas TRUTET"]
end

.available_optionsObject



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

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :entitlements_file,
                                 env_name: "FL_UPDATE_ASSOCIATED_DOMAINS_ENTITLEMENTS_FILE_PATH", # The name of the environment variable
                                 description: "The path to the entitlement file which contains the app group identifiers", # a short description of this parameter
                                 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: :app_associated_domains,
                                 env_name: "FL_UPDATE_ASSOCIATED_DOMAINS_ASSOCIATED_DOMAINS",
                                 description: "An Array of unique identifiers for the associated domains. Eg. ['com.apple.developer.associated-domains']",
                                 is_string: false,
                                 verify_block: proc do |value|
                                   UI.user_error!("The parameter app_associated_domains need to be an Array.") unless value.kind_of?(Array)
                                 end)
  ]
end

.descriptionObject



32
33
34
# File 'lib/fastlane/plugin/update_app_associated_domains/actions/update_app_associated_domains_action.rb', line 32

def self.description
  "[iOS] Replace associated domains array for the key <com.apple.developer.associated-domains> in the entitlement file."
end

.detailsObject



44
45
46
47
# File 'lib/fastlane/plugin/update_app_associated_domains/actions/update_app_associated_domains_action.rb', line 44

def self.details
  # Optional:
  "[iOS] Replace associated domains array for the key <com.apple.developer.associated-domains> in the entitlement file."
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


68
69
70
71
72
73
74
# File 'lib/fastlane/plugin/update_app_associated_domains/actions/update_app_associated_domains_action.rb', line 68

def self.is_supported?(platform)
  # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
  # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
  #
  # [:ios, :mac, :android].include?(platform)
  true
end

.return_valueObject



40
41
42
# File 'lib/fastlane/plugin/update_app_associated_domains/actions/update_app_associated_domains_action.rb', line 40

def self.return_value
  # If your method provides a return value, you can describe here what it does
end

.run(params) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/fastlane/plugin/update_app_associated_domains/actions/update_app_associated_domains_action.rb', line 9

def self.run(params)
  UI.message("Entitlements File: #{params[:entitlements_file]}")
  UI.message("New Associated Domains: #{params[:app_associated_domains]}")

  entitlements_file = params[:entitlements_file]
  UI.user_error!("Could not find entitlements file at path '#{entitlements_file}'") unless File.exist?(entitlements_file)

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

  # get app group field
  app_group_field = result['com.apple.developer.associated-domains']
  UI.user_error!("No existing associated domains specified. Please specify an associated domain in the entitlements file.") unless app_group_field

  # set new app group identifiers
  UI.message("Old Associated Domains: #{app_group_field}")
  result['com.apple.developer.associated-domains'] = params[:app_associated_domains]

  # save entitlements file
  result.save_plist(entitlements_file)
end