Class: Fastlane::Actions::EnsureXcodeBuildVersionAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/ensure_xcode_build_version/actions/ensure_xcode_build_version_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



27
28
29
# File 'lib/fastlane/plugin/ensure_xcode_build_version/actions/ensure_xcode_build_version_action.rb', line 27

def self.authors
  ["Fumiya Nakamura"]
end

.available_optionsObject



31
32
33
34
35
36
37
38
39
# File 'lib/fastlane/plugin/ensure_xcode_build_version/actions/ensure_xcode_build_version_action.rb', line 31

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

.descriptionObject



18
19
20
# File 'lib/fastlane/plugin/ensure_xcode_build_version/actions/ensure_xcode_build_version_action.rb', line 18

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

.detailsObject



22
23
24
25
# File 'lib/fastlane/plugin/ensure_xcode_build_version/actions/ensure_xcode_build_version_action.rb', line 22

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)


50
51
52
# File 'lib/fastlane/plugin/ensure_xcode_build_version/actions/ensure_xcode_build_version_action.rb', line 50

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

.outputObject



41
42
43
44
45
# File 'lib/fastlane/plugin/ensure_xcode_build_version/actions/ensure_xcode_build_version_action.rb', line 41

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

.return_valueObject



47
48
# File 'lib/fastlane/plugin/ensure_xcode_build_version/actions/ensure_xcode_build_version_action.rb', line 47

def self.return_value
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/fastlane/plugin/ensure_xcode_build_version/actions/ensure_xcode_build_version_action.rb', line 4

def self.run(params)
  required_build_version = params[:build_version]
  selected_build_version = sh("xcodebuild -version").match(/Build version (.*)$/)[1]

  if selected_build_version == required_build_version
    UI.success("Selected Xcode Build version is correct: #{selected_build_version}")
  else
    UI.message("Selected Xcode Build version is not correct: #{selected_build_version}. You expected #{required_build_version}.")
    UI.message("To correct this, use: `xcode_select(version: #{required_build_version})`.")

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