Class: Fastlane::Actions::UpdateProvisioningProfileSpecifierAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



44
45
46
# File 'lib/fastlane/plugin/update_provisioning_profile_specifier/actions/update_provisioning_profile_specifier_action.rb', line 44

def self.authors
  ["Jordan Bondo"]
end

.available_optionsObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/fastlane/plugin/update_provisioning_profile_specifier/actions/update_provisioning_profile_specifier_action.rb', line 48

def self.available_options
  [
    FastlaneCore::ConfigItem.new(
      key: :xcodeproj,
 env_name: "UPDATE_PROVISIONING_PROFILE_SPECIFIER_XCODEPROJ",
    description: "Path to the .xcodeproj file",
 optional: true,
   verify_block: proc do |value|
             UI.user_error!("Path to Xcode project file is invalid") unless File.exist?(value)
           end
    ),
    FastlaneCore::ConfigItem.new(
      key: :target,
 env_name: "UPDATE_PROVISIONING_PROFILE_SPECIFIER_TARGET",
    description: "The target for which to change the Provisioning Profile Specifier. If unspecified the change will be applied to all targets",
 optional: true
    ),
    FastlaneCore::ConfigItem.new(
      key: :new_specifier,
 env_name: "UPDATE_PROVISIONING_PROFILE_SPECIFIER_NEW_SPECIFIER",
    description: "Name of the new provisioning profile specifier to use, or to append to the existing value",
 optional: false
    ),
    FastlaneCore::ConfigItem.new(
      key: :append,
 env_name: "UPDATE_PROVISIONING_PROFILE_SPECIFIER_APPEND",
    description: ["True to append 'new_specifier' to the end of the exxisting specifier.",
            "This works well if you have provisioning profiles for the same project with different configurations, ",
            "'MyApp' and 'MyAppBeta', for example"].join('\n'),
 optional: true,
  default_value: false,
is_string: false
    )
  ]
end

.descriptionObject



40
41
42
# File 'lib/fastlane/plugin/update_provisioning_profile_specifier/actions/update_provisioning_profile_specifier_action.rb', line 40

def self.description
  "Update the provisioning profile in the Xcode Project file for a specified target"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


84
85
86
# File 'lib/fastlane/plugin/update_provisioning_profile_specifier/actions/update_provisioning_profile_specifier_action.rb', line 84

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
# File 'lib/fastlane/plugin/update_provisioning_profile_specifier/actions/update_provisioning_profile_specifier_action.rb', line 4

def self.run(params)
  require 'xcodeproj'

  specifier_key = 'PROVISIONING_PROFILE_SPECIFIER'

  # assign folder from the parameter or search for an .xcodeproj file
  pdir = params[:xcodeproj] || Dir["*.xcodeproj"].first

  # validate folder
  project_file_path = File.join(pdir, "project.pbxproj")
  UI.user_error!("Could not find path to project config '#{project_file_path}'. Pass the path to your project (NOT workspace!)") unless File.exist?(project_file_path)
  target = params[:target]

  project = Xcodeproj::Project.open(pdir)
  project.targets.each do |t|
    if !target || t.name.match(target)
      UI.success("Updating target #{t.name}")
    else
      UI.important("Skipping target #{t.name} as it doesn't match the filter '#{target}'")
      next
    end

    t.build_configuration_list.build_configurations.each do |config|
      if params[:append]
        cur = config.build_settings[specifier_key]
        config.build_settings[specifier_key] = cur + params[:new_specifier]
      else
        config.build_settings[specifier_key] = params[:new_specifier]
      end
    end
  end
  project.save

  UI.success("Successfully updated project settings in '#{params[:xcodeproj]}'")
end