Class: Fastlane::Actions::XcversionAction

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

Constant Summary

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES, Fastlane::Action::RETURN_TYPES

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, deprecated_notes, lane_context, method_missing, other_action, output, return_type, return_value, sample_return_value, shell_out_should_use_bundle_exec?, step_text

Class Method Details

.authorsObject



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

def self.authors
  ["oysta", "rogerluan"]
end

.available_optionsObject



43
44
45
46
47
48
49
50
51
52
# File 'fastlane/lib/fastlane/actions/xcversion.rb', line 43

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :version,
                                 env_name: "FL_XCODE_VERSION",
                                 description: "The version of Xcode to select specified as a Gem::Version requirement string (e.g. '~> 7.1.0')",
                                 default_value: self.read_xcode_version_file,
                                 default_value_dynamic: true,
                                 verify_block: Helper::XcversionHelper::Verify.method(:requirement))
  ]
end

.categoryObject



65
66
67
# File 'fastlane/lib/fastlane/actions/xcversion.rb', line 65

def self.category
  :building
end

.descriptionObject



28
29
30
# File 'fastlane/lib/fastlane/actions/xcversion.rb', line 28

def self.description
  "Select an Xcode to use by version specifier"
end

.detailsObject



32
33
34
35
36
37
# File 'fastlane/lib/fastlane/actions/xcversion.rb', line 32

def self.details
  [
    "Finds and selects a version of an installed Xcode that best matches the provided [`Gem::Version` requirement specifier](http://www.rubydoc.info/github/rubygems/rubygems/Gem/Version)",
    "You can either manually provide a specific version using `version:` or you make use of the `.xcode-version` file."
  ].join("\n")
end

.example_codeObject



58
59
60
61
62
63
# File 'fastlane/lib/fastlane/actions/xcversion.rb', line 58

def self.example_code
  [
    'xcversion(version: "8.1") # Selects Xcode 8.1.0',
    'xcversion(version: "~> 8.1.0") # Selects the latest installed version from the 8.1.x set'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:



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

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

.read_xcode_version_fileObject



18
19
20
21
22
23
24
25
26
# File 'fastlane/lib/fastlane/actions/xcversion.rb', line 18

def self.read_xcode_version_file
  xcode_version_paths = Dir.glob(".xcode-version")

  if xcode_version_paths.first
    return File.read(xcode_version_paths.first).strip
  end

  return nil
end

.run(params) ⇒ Object



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

def self.run(params)
  Actions.verify_gem!('xcode-install')

  version = params[:version]

  xcode = Helper::XcversionHelper.find_xcode(version)
  UI.user_error!("Cannot find an installed Xcode satisfying '#{version}'") if xcode.nil?

  UI.verbose("Found Xcode version #{xcode.version} at #{xcode.path} satisfying requirement #{version}")
  UI.message("Setting Xcode version to #{xcode.path} for all build steps")

  ENV["DEVELOPER_DIR"] = File.join(xcode.path, "/Contents/Developer")
end