Class: Fastlane::Actions::UpdateAppGroupIdentifiersAction

Inherits:
Fastlane::Action show all
Defined in:
fastlane/lib/fastlane/actions/update_app_group_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



69
70
71
# File 'fastlane/lib/fastlane/actions/update_app_group_identifiers.rb', line 69

def self.authors
  ["mathiasAichinger"]
end

.available_optionsObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'fastlane/lib/fastlane/actions/update_app_group_identifiers.rb', line 44

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 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_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 do |value|
                                   UI.user_error!("The parameter app_group_identifiers need to be an Array.") unless value.kind_of?(Array)
                                 end)
  ]
end

.categoryObject



86
87
88
# File 'fastlane/lib/fastlane/actions/update_app_group_identifiers.rb', line 86

def self.category
  :project
end

.descriptionObject



36
37
38
# File 'fastlane/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

.detailsObject



40
41
42
# File 'fastlane/lib/fastlane/actions/update_app_group_identifiers.rb', line 40

def self.details
  "Updates the App Group Identifiers in the given Entitlements file, so you can have app groups for the app store build and app groups for an enterprise build."
end

.example_codeObject



77
78
79
80
81
82
83
84
# File 'fastlane/lib/fastlane/actions/update_app_group_identifiers.rb', line 77

def self.example_code
  [
    'update_app_group_identifiers(
      entitlements_file: "/path/to/entitlements_file.entitlements",
      app_group_identifiers: ["group.your.app.group.identifier"]
    )'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:



73
74
75
# File 'fastlane/lib/fastlane/actions/update_app_group_identifiers.rb', line 73

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

.outputObject



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

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 'fastlane/lib/fastlane/actions/update_app_group_identifiers.rb', line 10

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

  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.security.application-groups']
  UI.user_error!("No existing App group field specified. Please specify an App Group in the entitlements file.") unless app_group_field

  # set new app group identifiers
  UI.message("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)
  UI.message("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