Class: Fastlane::Actions::CosignerAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



51
52
53
# File 'lib/fastlane/plugin/cosigner/actions/cosigner_action.rb', line 51

def self.authors
  ["mindera.com", "p4checo", "portellaa"]
end

.available_optionsObject



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/fastlane/plugin/cosigner/actions/cosigner_action.rb', line 77

def self.available_options
  [
      FastlaneCore::ConfigItem.new(key: :xcodeproj_path,
                                   env_name: "PROJECT_PATH",
                                   description: "The Project Path"),
      FastlaneCore::ConfigItem.new(key: :scheme,
                                   env_name: "SCHEME",
                                   description: "Scheme"),
      FastlaneCore::ConfigItem.new(key: :build_configuration,
                                   env_name: "BUILD_CONFIGURATION",
                                   description: "Build configuration (Debug, Release, ...)"),
      FastlaneCore::ConfigItem.new(key: :code_sign_style,
                                   env_name: "CODE_SIGN_STYLE",
                                   description: "Code Sign (Provisioning) style (Automatic, Manual)",
                                   default_value: "Manual"),
      FastlaneCore::ConfigItem.new(key: :code_sign_identity,
                                   env_name: "CODE_SIGN_IDENTITY",
                                   description: "Code signing identity type (iPhone Development, iPhone Distribution)",
                                   default_value: "iPhone Distribution"),
      FastlaneCore::ConfigItem.new(key: :profile_name,
                                   env_name: "PROVISIONING_PROFILE_SPECIFIER",
                                   description: "Provisioning profile name to use for code signing"),
      FastlaneCore::ConfigItem.new(key: :profile_uuid,
                                   env_name: "PROVISIONING_PROFILE",
                                   description: "Provisioning profile UUID to use for code signing",
                                   optional: true),
      FastlaneCore::ConfigItem.new(key: :development_team,
                                   env_name: "TEAM_ID",
                                   description: "Development team identifier",
                                   optional: true),
      FastlaneCore::ConfigItem.new(key: :bundle_identifier,
                                   env_name: "APP_IDENTIFIER",
                                   description: "Application Product Bundle Identifier",
                                   optional: true)
  ]
end

.descriptionObject



47
48
49
# File 'lib/fastlane/plugin/cosigner/actions/cosigner_action.rb', line 47

def self.description
  "A fastlane plugin to help you sign your iOS builds"
end

.detailsObject



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/fastlane/plugin/cosigner/actions/cosigner_action.rb', line 55

def self.details
  "
Fastlane plugin which enables iOS workflows to change the Xcode project's code signing settings before building a target, being a \"cosigner\" 🖋.

This action is especially useful to avoid having to configure the Xcode project with a \"static\" set of code signing configurations for:

 * Code Signing Style (Xcode8+): Manual / Automatic (also called Provisioning Style on Xcode 8)
 * Code Signing Identity: iPhone Development / iPhone Distribution
 * Provisioning Profile UUID (Xcode 7 and earlier)
 * Provisioning Profile Name (Xcode8+)
 * Team ID
 * Application Bundle identifier

By being able to configure this before each build (e.g. `gym` call), it allows having separate sets of code signing configurations on the same project without being \"intrusive\".

Some practical scenarios can be for example:

 * Xcode project in which two different Apple Developer accounts/teams are required (e.g. 1 for Development and 1 for Release)
 * Shared Xcode project where teams have different code signing configurations (e.g. Automatic vs Manual Provisioning Style)
  "
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


114
115
116
# File 'lib/fastlane/plugin/cosigner/actions/cosigner_action.rb', line 114

def self.is_supported?(platform)
  [:ios, :mac].include?(platform)
end

.run(params) ⇒ Object



4
5
6
7
8
9
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
43
44
45
# File 'lib/fastlane/plugin/cosigner/actions/cosigner_action.rb', line 4

def self.run(params)
  require 'xcodeproj'
  require 'colorize'

  project = Xcodeproj::Project.open(params[:xcodeproj_path])

  target = project.targets.select{ |target| target.name == params[:scheme] }.first
  project_attributes = project.root_object.attributes
  build_settings = target.build_configuration_list[params[:build_configuration]].build_settings

  # The new `ProvisioningStyle` setting on Xcode 8 apparently was migrated to the `CODE_SIGN_STYLE` build setting
  # Since we can't know for sure which Xcode version is running, apply both values
  UI.message "Updating Xcode project's `ProvisioningStyle` (Xcode 8) and `CODE_SIGN_STYLE` (Xcode 9+) to \"#{params[:code_sign_style]}\" 🛠".green
  project_attributes['TargetAttributes'][target.uuid]['ProvisioningStyle'] = params[:code_sign_style]
  build_settings['CODE_SIGN_STYLE'] = params[:code_sign_identity]

  UI.message "Updating Xcode project's `CODE_SIGN_IDENTITY` to \"#{params[:code_sign_identity]}\" 🔑".green
  build_settings['CODE_SIGN_IDENTITY'] = params[:code_sign_identity]
  build_settings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'] = params[:code_sign_identity]

  UI.message "Updating Xcode project's `PROVISIONING_PROFILE_SPECIFIER` to \"#{params[:profile_name]}\" 🔧".green
  build_settings['PROVISIONING_PROFILE_SPECIFIER'] = params[:profile_name]

  # This item is set as optional in the configuration values
  # Since Xcode 8, this is no longer needed, you use PROVISIONING_PROFILE_SPECIFIER
  if params[:profile_uuid]
      UI.message "Updating Xcode project's `PROVISIONING_PROFILE` to \"#{params[:profile_uuid]}\" 🔧".green
      build_settings['PROVISIONING_PROFILE'] = params[:profile_uuid]
  end

  if params[:development_team]
      UI.message "Updating Xcode project's `DEVELOPMENT_TEAM` to \"#{params[:development_team]}\" 👯".green
      build_settings['DEVELOPMENT_TEAM'] = params[:development_team]
  end

  if params[:bundle_identifier]
      UI.message "Updating Xcode project's `PRODUCT_BUNDLE_IDENTIFIER` \"#{params[:bundle_identifier]}\" 🤗".green
      build_settings['PRODUCT_BUNDLE_IDENTIFIER'] = params[:bundle_identifier]
  end

  project.save
end