class Fastlane::Actions::WaitXcrunAction

Public Class Methods

authors() click to toggle source
# File lib/fastlane/plugin/wait_xcrun/actions/wait_xcrun_action.rb, line 39
def self.authors
  ["mgrebenets"]
end
description() click to toggle source
# File lib/fastlane/plugin/wait_xcrun/actions/wait_xcrun_action.rb, line 25
def self.description
  "Wait for Xcode toolchain to come back online after switching Xcode versions."
end
details() click to toggle source
# File lib/fastlane/plugin/wait_xcrun/actions/wait_xcrun_action.rb, line 29
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) click to toggle source
# File lib/fastlane/plugin/wait_xcrun/actions/wait_xcrun_action.rb, line 43
def self.is_supported?(platform)
  [:ios, :mac].include?(platform)
end
run(params) click to toggle source
# File lib/fastlane/plugin/wait_xcrun/actions/wait_xcrun_action.rb, line 4
def self.run(params)
  unless system("command -v xcrun")
    UI.important("xcrun command does not exist")
    return
  end

  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