Class: Fastlane::Actions::UpdateProjectTeamAction

Inherits:
Fastlane::Action show all
Defined in:
fastlane/lib/fastlane/actions/update_project_team.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, authors, deprecated_notes, lane_context, method_missing, other_action, output, return_type, return_value, sample_return_value, shell_out_should_use_bundle_exec?, step_text

Class Method Details

.authorObject



72
73
74
# File 'fastlane/lib/fastlane/actions/update_project_team.rb', line 72

def self.author
  "lgaches"
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
# File 'fastlane/lib/fastlane/actions/update_project_team.rb', line 48

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :path,
                                 env_name: "FL_PROJECT_SIGNING_PROJECT_PATH",
                                 description: "Path to your Xcode project",
                                 default_value: Dir['*.xcodeproj'].first,
                                 default_value_dynamic: true,
                                 verify_block: proc do |value|
                                   UI.user_error!("Path is invalid") unless File.exist?(value)
                                 end),
    FastlaneCore::ConfigItem.new(key: :targets,
                                 env_name: "FL_PROJECT_TARGET",
                                 description: "Name of the targets you want to update",
                                 type: Array,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :teamid,
                                 env_name: "FL_PROJECT_TEAM_ID",
                                 description: "The Team ID you want to use",
                                 code_gen_sensitive: true,
                                 default_value: ENV["TEAM_ID"] || CredentialsManager::AppfileConfig.try_fetch_value(:team_id),
                                 default_value_dynamic: true)
  ]
end

.categoryObject



90
91
92
# File 'fastlane/lib/fastlane/actions/update_project_team.rb', line 90

def self.category
  :project
end

.descriptionObject



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

def self.description
  "Update Xcode Development Team ID"
end

.detailsObject



44
45
46
# File 'fastlane/lib/fastlane/actions/update_project_team.rb', line 44

def self.details
  "This action updates the Developer Team ID of your Xcode project."
end

.example_codeObject



80
81
82
83
84
85
86
87
88
# File 'fastlane/lib/fastlane/actions/update_project_team.rb', line 80

def self.example_code
  [
    'update_project_team',
    'update_project_team(
      path: "Example.xcodeproj",
      teamid: "A3ZZVJ7CNY"
    )'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:



76
77
78
# File 'fastlane/lib/fastlane/actions/update_project_team.rb', line 76

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

.run(params) ⇒ Object



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

def self.run(params)
  project_path = params[:path]
  selected_targets = params[:targets]

  UI.user_error!("Could not find path to xcodeproj '#{project_path}'. Pass the path to your project (not workspace)!") unless File.exist?(project_path)

  # Load .xcodeproj
  project = Xcodeproj::Project.open(project_path)

  # Fetch target
  targets = project.native_targets
  if selected_targets
    # Error to user if invalid target
    diff_targets = selected_targets - targets.map(&:name)
    UI.user_error!("Could not find target(s) in the project '#{project_path}' - #{diff_targets.join(',')}") unless diff_targets.empty?

    targets.select! { |native_target| selected_targets.include?(native_target.name) }
  end

  # Set teamid in target
  targets.each do |target|
    UI.message("Updating development team (#{params[:teamid]}) for target `#{target.name}` in the project '#{project_path}'")
    # Update the build settings
    target.build_configurations.each do |configuration|
      configuration.build_settings['DEVELOPMENT_TEAM'] = params[:teamid]
    end

    project.save

    UI.success("Successfully updated project settings to use Developer Team ID '#{params[:teamid]}' for target `#{target.name}`")
  end
end