class Fastlane::Actions::UpdateProjectTeamAction

Public Class Methods

author() click to toggle source
# File fastlane/lib/fastlane/actions/update_project_team.rb, line 72
def self.author
  "lgaches"
end
available_options() click to toggle source
# 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
category() click to toggle source
# File fastlane/lib/fastlane/actions/update_project_team.rb, line 90
def self.category
  :project
end
description() click to toggle source
# File fastlane/lib/fastlane/actions/update_project_team.rb, line 40
def self.description
  "Update Xcode Development Team ID"
end
details() click to toggle source
# 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_code() click to toggle source
# 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) click to toggle source
# File fastlane/lib/fastlane/actions/update_project_team.rb, line 76
def self.is_supported?(platform)
  [:ios, :mac].include?(platform)
end
run(params) click to toggle source
# 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