Class: Fastlane::Actions::XcodeInstallAction

Inherits:
Fastlane::Action show all
Defined in:
lib/fastlane/actions/xcode_install.rb

Constant Summary

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES

Documentation collapse

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, lane_context, method_missing, other_action, sample_return_value, sh, step_text

Class Method Details

.authorsObject



77
78
79
# File 'lib/fastlane/actions/xcode_install.rb', line 77

def self.authors
  ["Krausefx"]
end

.available_optionsObject



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

def self.available_options
  user = CredentialsManager::AppfileConfig.try_fetch_value(:apple_dev_portal_id)
  user ||= CredentialsManager::AppfileConfig.try_fetch_value(:apple_id)

  [
    FastlaneCore::ConfigItem.new(key: :version,
                                 env_name: "FL_XCODE_VERSION",
                                 description: "The version number of the version of Xcode to install",
                                 verify_block: proc do |value|
                                 end),
    FastlaneCore::ConfigItem.new(key: :username,
                                 short_option: "-u",
                                 env_name: "XCODE_INSTALL_USER",
                                 description: "Your Apple ID Username",
                                 default_value: user),
    FastlaneCore::ConfigItem.new(key: :team_id,
                                 short_option: "-b",
                                 env_name: "XCODE_INSTALL_TEAM_ID",
                                 description: "The ID of your team if you're in multiple teams",
                                 optional: true,
                                 default_value: CredentialsManager::AppfileConfig.try_fetch_value(:team_id))
  ]
end

.categoryObject



91
92
93
# File 'lib/fastlane/actions/xcode_install.rb', line 91

def self.category
  :building
end

.descriptionObject



35
36
37
# File 'lib/fastlane/actions/xcode_install.rb', line 35

def self.description
  "Make sure a certain version of Xcode is installed"
end

.detailsObject



39
40
41
# File 'lib/fastlane/actions/xcode_install.rb', line 39

def self.details
  "Makes sure a specific version of Xcode is installed. If that's not the case, it will automatically be downloaded by the [xcode_install](https://github.com/neonichu/xcode-install) gem. This will make sure to use the correct Xcode for later actions."
end

.example_codeObject



85
86
87
88
89
# File 'lib/fastlane/actions/xcode_install.rb', line 85

def self.example_code
  [
    'xcode_install(version: "7.1")'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


81
82
83
# File 'lib/fastlane/actions/xcode_install.rb', line 81

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

.outputObject



67
68
69
70
71
# File 'lib/fastlane/actions/xcode_install.rb', line 67

def self.output
  [
    ['XCODE_INSTALL_CUSTOM_VALUE', 'A description of what this value contains']
  ]
end

.return_valueObject



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

def self.return_value
  "The path to the newly installed Xcode version"
end

.run(params) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fastlane/actions/xcode_install.rb', line 8

def self.run(params)
  ENV["XCODE_INSTALL_USER"] = params[:username]
  ENV["XCODE_INSTALL_TEAM_ID"] = params[:team_id]

  require 'xcode/install'
  installer = XcodeInstall::Installer.new

  if installer.installed?(params[:version])
    UI.success("Xcode #{params[:version]} is already installed ✨")
  else
    installer.install_version(params[:version], true, true, true, true)
  end

  xcode = installer.installed_versions.find { |x| x.version == params[:version] }
  UI.user_error!("Could not find Xcode with version '#{params[:version]}'") unless xcode
  UI.message("Using Xcode #{params[:version]} on path '#{xcode.path}'")
  xcode.approve_license

  ENV["DEVELOPER_DIR"] = File.join(xcode.path, "/Contents/Developer")
  Actions.lane_context[SharedValues::XCODE_INSTALL_XCODE_PATH] = xcode.path
  return xcode.path
end