Class: Fastlane::Actions::EnsureSwiftVersionAction

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

Class Method Summary collapse

Class Method Details

.authorsObject


21
22
23
# File 'lib/fastlane/plugin/ensure_swift_version/actions/ensure_swift_version_action.rb', line 21

def self.authors
  ["Shashikant86"]
end

.available_optionsObject


34
35
36
37
38
39
40
41
42
# File 'lib/fastlane/plugin/ensure_swift_version/actions/ensure_swift_version_action.rb', line 34

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

.categoryObject


44
45
46
# File 'lib/fastlane/plugin/ensure_swift_version/actions/ensure_swift_version_action.rb', line 44

def self.category
  :building
end

.descriptionObject


17
18
19
# File 'lib/fastlane/plugin/ensure_swift_version/actions/ensure_swift_version_action.rb', line 17

def self.description
  "This plugin ensure version of Swift language used for project"
end

.detailsObject


29
30
31
32
# File 'lib/fastlane/plugin/ensure_swift_version/actions/ensure_swift_version_action.rb', line 29

def self.details
  # Optional:
  "This plugin can be used in before_all lane to check if version of Swift is correct before building app"
end

.example_codeObject


48
49
50
# File 'lib/fastlane/plugin/ensure_swift_version/actions/ensure_swift_version_action.rb', line 48

def self.example_code
  ['check_swift_version(version: "Apple Swift version 3.0.2")']
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)

52
53
54
# File 'lib/fastlane/plugin/ensure_swift_version/actions/ensure_swift_version_action.rb', line 52

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

.return_valueObject


25
26
27
# File 'lib/fastlane/plugin/ensure_swift_version/actions/ensure_swift_version_action.rb', line 25

def self.return_value
  # If your method provides a return value, you can describe here what it does
end

.run(params) ⇒ Object


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

def self.run(params)
  UI.message("The ensure_swift_version plugin is working!")
  required_version = params[:version]
  selected_version = sh("swift -version")
  if selected_version.include?(required_version)
    UI.success("Selected Swift version is correct: #{selected_version}")
  else
    UI.message("Selected Swift version is not correct: #{selected_version}. You expected #{required_version}.")
    UI.message("To correct this, make sure you are using right Swift toolchain Or Xcode version")
    UI.user_error!("Selected Swift version doesn't match your requirement.\nExpected: #{required_version}\nActual: #{selected_version}\n")
  end
end