<commit_before>module Fastlane
  module Actions
    class WaitXcrunAction < Action
      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

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

      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

      def self.authors
        ["mgrebenets"]
      end

      def self.is_supported?(platform)
        [:ios, :mac].include?(platform)
      end
    end
  end
end
<commit_msg>Check if xcrun command exists<commit_after>module Fastlane
  module Actions
    class WaitXcrunAction < Action
      def self.run(params)
        xcrun_cmd = "xcrun"
        unless system("command -v #{xcrun_cmd}")
          UI.important("#{xcrun_cmd} 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_cmd} 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

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

      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

      def self.authors
        ["mgrebenets"]
      end

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

{'fraction_non_alphanumeric': 0.09221311475409837, 'fraction_numerical': 0.010245901639344262, 'mean_word_length': 2.013374485596708, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6886956', 'n_tokens_mistral': 849, 'n_tokens_neox': 807, 'n_words': 295}