Class: PodPrebuild::XcodebuildCommand
- Inherits:
-
Object
- Object
- PodPrebuild::XcodebuildCommand
- Defined in:
- lib/cocoapods-binary-cache/pod-rome/xcodebuild_command.rb,
lib/cocoapods-binary-cache/pod-rome/xcodebuild_raw.rb
Overview
rubocop:disable Metrics/ClassLength
Constant Summary collapse
- PLATFORM_OF_SDK =
{ "iphonesimulator" => "iOS", "appletvsimulator" => "tvOS", "watchsimulator" => "watchOS" }.freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options) ⇒ XcodebuildCommand
constructor
A new instance of XcodebuildCommand.
- #run ⇒ Object
Constructor Details
#initialize(options) ⇒ XcodebuildCommand
Returns a new instance of XcodebuildCommand.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/cocoapods-binary-cache/pod-rome/xcodebuild_command.rb', line 5 def initialize() @options = case [:targets][0].platform.name when :ios @options[:device] = "iphoneos" @options[:simulator] = "iphonesimulator" when :tvos @options[:device] = "appletvos" @options[:simulator] = "appletvsimulator" when :watchos @options[:device] = "watchos" @options[:simulator] = "watchsimulator" end @build_args = make_up_build_args([:args] || {}) end |
Class Method Details
.xcodebuild(options) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/cocoapods-binary-cache/pod-rome/xcodebuild_raw.rb', line 11 def self.xcodebuild() sdk = [:sdk] || "iphonesimulator" targets = [:targets] || [[:target]] platform = PLATFORM_OF_SDK[sdk] cmd = ["xcodebuild"] cmd << "-project" << [:sandbox].project_path.realdirpath.shellescape targets.each { |target| cmd << "-target" << target } cmd << "-configuration" << [:configuration] cmd << "-sdk" << sdk unless platform.nil? cmd << Fourflusher::SimControl.new.destination(:oldest, platform, [:deployment_target]) end cmd += [:args] if [:args] cmd << "build" cmd << "2>&1" cmd = cmd.join(" ") Pod::UI.puts_indented "$ #{cmd}" log = `#{cmd}` return if $?.exitstatus.zero? # rubocop:disable Style/SpecialGlobalVars begin 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 Pod::UI.puts log.red ensure raise "Fail to build targets: #{targets}" end end |
Instance Method Details
#run ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/cocoapods-binary-cache/pod-rome/xcodebuild_command.rb', line 21 def run build_for_sdk(simulator) if build_types.include?(:simulator) build_for_sdk(device) if build_types.include?(:device) targets.each do |target| case build_types when [:simulator] collect_output(target, Dir[target_products_dir_of(target, simulator) + "/*"]) when [:device] collect_output(target, Dir[target_products_dir_of(target, device) + "/*"]) else # When merging contents of `simulator` & `device`, prefer contents of `device` over `simulator` # https://github.com/grab/cocoapods-binary-cache/issues/25 collect_output(target, Dir[target_products_dir_of(target, device) + "/*"]) create_universal_framework(target) end end end |