Class: Fastlane::Actions::UpdateAppGroupIdentifiersAction

Inherits:
Fastlane::Action show all
Defined in:
lib/fastlane/actions/update_app_group_identifiers.rb

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, details, sh, step_text

Class Method Details

.authorsObject



63
64
65
# File 'lib/fastlane/actions/update_app_group_identifiers.rb', line 63

def self.authors
  ["mathiasAichinger"]
end

.available_optionsObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/fastlane/actions/update_app_group_identifiers.rb', line 40

def self.available_options
  [
      FastlaneCore::ConfigItem.new(key: :entitlements_file,
                                   env_name: "FL_UPDATE_APP_GROUP_IDENTIFIER_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.new do |value|
                                     raise "Please pass a path to an entitlements file. ".red unless value.include? ".entitlements"
                                     raise "Could not find entitlements file".red if (not File.exists?(value) and not Helper.is_test?)
                                   end),
      FastlaneCore::ConfigItem.new(key: :app_group_identifiers,
                                   env_name: "FL_UPDATE_APP_GROUP_IDENTIFIER_APP_GROUP_IDENTIFIERS",
                                   description: "An Array of unique identifiers for the app groups. Eg. ['group.com.test.testapp']",
                                   is_string: false,
                                   verify_block: Proc.new do |value|
                                     raise "The parameter app_group_identifiers need to be an Array.".red unless value.is_a? Array
                                   end)
  ]
end

.descriptionObject



36
37
38
# File 'lib/fastlane/actions/update_app_group_identifiers.rb', line 36

def self.description
  "This action changes the app group identifiers in the entitlements file"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


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

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

.outputObject



59
60
61
# File 'lib/fastlane/actions/update_app_group_identifiers.rb', line 59

def self.output
  ['APP_GROUP_IDENTIFIERS', 'The new App Group 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
# File 'lib/fastlane/actions/update_app_group_identifiers.rb', line 10

def self.run(params)
  Helper.log.info "Entitlements File: #{params[:entitlements_file]}"
  Helper.log.info "New App Group Identifiers: #{params[:app_group_identifiers]}"

  entitlements_file = params[:entitlements_file]
  raise "Could not find entitlements file at path '#{entitlements_file}'".red unless File.exists?(entitlements_file)

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

  # get app group field
  app_group_field = result['com.apple.security.application-groups']
  raise 'No existing App group field specified. Please specify an App Group in the entitlements file.'.red unless app_group_field

  # set new app group identifiers
  Helper.log.info "Old App Group Identifiers: #{app_group_field}"
  result['com.apple.security.application-groups'] = params[:app_group_identifiers]

  # save entitlements file
  result.save_plist(entitlements_file)
  Helper.log.info "New App Group Identifiers set: #{result['com.apple.security.application-groups']}"

  Actions.lane_context[SharedValues::APP_GROUP_IDENTIFIERS] = result['com.apple.security.application-groups']
end