Sha256: 9aa2c993088bf8bf283d5fb096148d6b58fca13690391f9642ae3f237b10cd74

Contents?: true

Size: 1.23 KB

Versions: 2

Compression:

Stored size: 1.23 KB

Contents

require "fourflusher"

PLATFORM_OF_SDK = {
  "iphonesimulator" => "iOS",
  "appletvsimulator" => "tvOS",
  "watchsimulator" => "watchOS"
}.freeze

def xcodebuild(options)
  sdk = options[:sdk] || "iphonesimulator"
  platform = PLATFORM_OF_SDK[sdk]

  cmd = ["xcodebuild"]
  cmd << "-project" << options[:sandbox].project_path.realdirpath
  cmd << "-scheme" << options[:target]
  cmd << "-configuration" << options[:configuration]
  cmd << "-sdk" << sdk
  cmd << Fourflusher::SimControl.new.destination(:oldest, platform, options[:deployment_target]) unless platform.nil?
  cmd += options[:args] if options[:args]
  cmd << "2>&1"
  cmd = cmd.join(" ")

  puts "xcodebuild command: #{cmd}"
  log = `#{cmd}`

  succeeded = $?.exitstatus.zero?
  unless succeeded
    begin
      raise "Unexpected error" unless log.include?("** BUILD FAILED **")

      require "xcpretty" # TODO (thuyen): Revise this dependency
      # use xcpretty to print build log
      # 64 represent command invalid. http://www.manpagez.com/man/3/sysexits/
      printer = XCPretty::Printer.new({:formatter => XCPretty::Simple, :colorize => "auto"})
      log.each_line do |line|
        printer.pretty_print(line)
      end
    rescue
      puts log.red
    end
  end
  [succeeded, log]
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cocoapods-binary-cache-0.1.7 lib/cocoapods-binary-cache/pod-rome/xcodebuild_raw.rb
cocoapods-binary-cache-0.1.6 lib/cocoapods-binary-cache/pod-rome/xcodebuild_raw.rb