Class: Fastlane::Actions::EnsureXcodeVersionAction
Constant Summary
Fastlane::Action::AVAILABLE_CATEGORIES, Fastlane::Action::RETURN_TYPES
Class Method Summary
collapse
action_name, author, deprecated_notes, lane_context, method_missing, other_action, return_type, sample_return_value, shell_out_should_use_bundle_exec?, step_text
Class Method Details
.authors ⇒ Object
82
83
84
|
# File 'fastlane/lib/fastlane/actions/ensure_xcode_version.rb', line 82
def self.authors
["JaviSoto", "KrauseFx"]
end
|
.available_options ⇒ Object
63
64
65
66
67
68
69
70
71
|
# File 'fastlane/lib/fastlane/actions/ensure_xcode_version.rb', line 63
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: true)
]
end
|
.category ⇒ Object
92
93
94
|
# File 'fastlane/lib/fastlane/actions/ensure_xcode_version.rb', line 92
def self.category
:building
end
|
.description ⇒ Object
51
52
53
|
# File 'fastlane/lib/fastlane/actions/ensure_xcode_version.rb', line 51
def self.description
"Ensure the right version of Xcode is used"
end
|
.details ⇒ Object
55
56
57
58
59
60
61
|
# File 'fastlane/lib/fastlane/actions/ensure_xcode_version.rb', line 55
def self.details
[
"If building your app requires a specific version of Xcode, you can invoke this command before using gym.",
"For example, to ensure that a beta version of Xcode is not accidentally selected to build, which would make uploading to TestFlight fail.",
"You can either manually provide a specific version using `version: ` or you make use of the `.xcode-version` file."
].join("\n")
end
|
.example_code ⇒ Object
86
87
88
89
90
|
# File 'fastlane/lib/fastlane/actions/ensure_xcode_version.rb', line 86
def self.example_code
[
'ensure_xcode_version(version: "7.2")'
]
end
|
.is_supported?(platform) ⇒ Boolean
96
97
98
|
# File 'fastlane/lib/fastlane/actions/ensure_xcode_version.rb', line 96
def self.is_supported?(platform)
[:ios, :mac].include?(platform)
end
|
.output ⇒ Object
73
74
75
76
77
|
# File 'fastlane/lib/fastlane/actions/ensure_xcode_version.rb', line 73
def self.output
[
['FL_ENSURE_XCODE_VERSION', 'Xcode version to verify that is selected']
]
end
|
.return_value ⇒ Object
79
80
|
# File 'fastlane/lib/fastlane/actions/ensure_xcode_version.rb', line 79
def self.return_value
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'fastlane/lib/fastlane/actions/ensure_xcode_version.rb', line 8
def self.run(params)
Actions.verify_gem!('xcode-install')
required_version = params[:version]
if required_version.to_s.length == 0
xcode_version_paths = Dir.glob(".xcode-version")
if xcode_version_paths.first
UI.verbose("Loading required version from #{xcode_version_paths.first}")
required_version = File.read(xcode_version_paths.first).strip
else
UI.user_error!("No version: provided when calling the `ensure_xcode_version` action")
end
end
selected_version = sh("xcversion selected").match(/^Xcode (.*)$/)[1]
begin
selected_version = Gem::Version.new(selected_version)
required_version = Gem::Version.new(required_version)
rescue ArgumentError => ex
UI.user_error!("Invalid version number provided, make sure it's valid: #{ex}")
end
if selected_version == required_version
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: Xcode #{selected_version}\n")
end
end
|