Class: Fastlane::Actions::EnsureXcodeVersionAction

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

Documentation collapse

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, method_missing, other_action, sh, step_text

Class Method Details

.authorsObject



57
58
59
# File 'lib/fastlane/actions/ensure_xcode_version.rb', line 57

def self.authors
  ["JaviSoto"]
end

.available_optionsObject



38
39
40
41
42
43
44
45
46
# File 'lib/fastlane/actions/ensure_xcode_version.rb', line 38

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :version,
                                 env_name: "FL_ENSURE_XCODE_VERSION",
                                 description: "Xcode version to verify that is selected",
                                 is_string: true,
                                 optional: false)
  ]
end

.descriptionObject



29
30
31
# File 'lib/fastlane/actions/ensure_xcode_version.rb', line 29

def self.description
  "Ensure the selected Xcode version with xcode-select matches a value"
end

.detailsObject



33
34
35
36
# File 'lib/fastlane/actions/ensure_xcode_version.rb', line 33

def self.details
  "If building your app requires a specific version of Xcode, you can invoke this command before using gym.\n
  For example, to ensure that a beta version is not accidentally selected to build, which would make uploading to TestFlight fail."
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/fastlane/actions/ensure_xcode_version.rb', line 61

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

.outputObject



48
49
50
51
52
# File 'lib/fastlane/actions/ensure_xcode_version.rb', line 48

def self.output
  [
    ['FL_ENSURE_XCODE_VERSION', 'Xcode version to verify that is selected']
  ]
end

.return_valueObject



54
55
# File 'lib/fastlane/actions/ensure_xcode_version.rb', line 54

def self.return_value
end

.run(params) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fastlane/actions/ensure_xcode_version.rb', line 8

def self.run(params)
  required_version = params[:version]

  selected_version = sh "xcversion selected | head -1 | xargs echo -n"

  versions_match = selected_version == "Xcode #{required_version}"

  if versions_match
    UI.success("Selected Xcode version is correct: #{selected_version}")
  else
    UI.message("Selected Xcode version is not correct: #{selected_version}. You expected #{required_version}.")
    UI.message("To correct this, use: `xcode_select(version: #{required_version})`.")

    UI.user_error!("Selected Xcode version doesn't match your requirement.\nExpected: Xcode #{required_version}\nActual: #{selected_version}\n")
  end
end