Class: Fastlane::Actions::WaitXcrunAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



33
34
35
# File 'lib/fastlane/plugin/wait_xcrun/actions/wait_xcrun_action.rb', line 33

def self.authors
  ["mgrebenets"]
end

.descriptionObject



19
20
21
# File 'lib/fastlane/plugin/wait_xcrun/actions/wait_xcrun_action.rb', line 19

def self.description
  "Wait for Xcode toolchain to come back online after switching Xcode versions."
end

.detailsObject



23
24
25
26
27
28
29
30
31
# File 'lib/fastlane/plugin/wait_xcrun/actions/wait_xcrun_action.rb', line 23

def self.details
  [
    "This action helps fixing the following issue:",
    "- Launch Xcode 8 simulator",
    "- Run any 'xcrun simctl' sub-command using Xcode 7.3.1 toolchain",
    "",
    "In most cases the 'xcrun' command will cause an exception and will return exit code 134."
  ].join("\n")
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/fastlane/plugin/wait_xcrun/actions/wait_xcrun_action.rb', line 37

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

.run(params) ⇒ Object



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

def self.run(params)
  UI.message "Waiting for Xcode toolchain ..."
  # Try running 'xcrun simctl help' subcommand until exit status is 0 or max number or retries is exceeded
  retry_count = 0
  loop do
    system("xcrun simctl help 2>/dev/null 1>/dev/null")
    break if $?.success? || retry_count >= 10
    UI.important("Xcode toochain is not ready yet. Retrying ...")
    sleep(1) # Take a short break
    retry_count += 1
  end

  $?.success? ? UI.success("Xcode toolchain is back online!") : UI.user_error!("Xcode toolchain is offline.")
end