Top Level Namespace
Defined Under Namespace
Modules: CocoapodsBinaryBugfix, Pod
Constant Summary collapse
- CONFIGURATION =
"Debug"
- PLATFORMS =
{ 'iphonesimulator' => 'iOS', 'appletvsimulator' => 'tvOS', 'watchsimulator' => 'watchOS' }
Instance Method Summary collapse
-
#build_for_iosish_platform(sandbox, build_dir, output_path, target, device, simulator, bitcode_enabled, custom_build_options = [], custom_build_options_simulator = []) ⇒ Object
Build specific target to framework file @param [PodTarget] target a specific pod target.
-
#class_attr_accessor(symbol) ⇒ Object
attr_accessor for class variable.
- #xcodebuild(sandbox, target, sdk = 'macosx', deployment_target = nil, other_options = []) ⇒ Object
Instance Method Details
#build_for_iosish_platform(sandbox, build_dir, output_path, target, device, simulator, bitcode_enabled, custom_build_options = [], custom_build_options_simulator = []) ⇒ Object
Build specific target to framework file
@param [PodTarget] target
a specific pod target
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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/cocoapods-binary-bugfix/rome/build_framework.rb', line 13 def build_for_iosish_platform(sandbox, build_dir, output_path, target, device, simulator, bitcode_enabled, = [], # Array<String> = [] # Array<String> ) deployment_target = target.platform.deployment_target.to_s target_label = target.label # name with platform if it's used in multiple platforms Pod::UI.puts "Prebuilding #{target_label}..." = [] # bitcode enabled += ['BITCODE_GENERATION_MODE=bitcode'] if bitcode_enabled # make less arch to iphone simulator for faster build += ['ARCHS=x86_64', 'ONLY_ACTIVE_ARCH=NO'] if simulator == 'iphonesimulator' is_succeed, _ = xcodebuild(sandbox, target_label, device, deployment_target, + ) exit 1 unless is_succeed is_succeed, _ = xcodebuild(sandbox, target_label, simulator, deployment_target, + ) exit 1 unless is_succeed # paths target_name = target.name # equals target.label, like "AFNeworking-iOS" when AFNetworking is used in multiple platforms. module_name = target.product_module_name device_framework_path = "#{build_dir}/#{CONFIGURATION}-#{device}/#{target_name}/#{module_name}.framework" simulator_framework_path = "#{build_dir}/#{CONFIGURATION}-#{simulator}/#{target_name}/#{module_name}.framework" device_binary = device_framework_path + "/#{module_name}" simulator_binary = simulator_framework_path + "/#{module_name}" # if device_binary exist && simulator_binary exist 继续执行下面的代码 # else return return unless File.file?(device_binary) || File.file?(simulator_binary) # the device_lib path is the final output file path # combine the binaries tmp_lipoed_binary_path = "#{build_dir}/#{target_name}" if File.file?(device_binary) && File.file?(simulator_binary) lipo_log = `lipo -create -output #{tmp_lipoed_binary_path} #{device_binary} #{simulator_binary}` elsif File.file?(device_binary) lipo_log = `lipo -create -output #{tmp_lipoed_binary_path} #{device_binary}` else lipo_log = `lipo -create -output #{tmp_lipoed_binary_path} #{simulator_binary}` end puts lipo_log unless File.exist?(tmp_lipoed_binary_path) FileUtils.mv tmp_lipoed_binary_path, device_binary, :force => true # collect the swiftmodule file for various archs. device_swiftmodule_path = device_framework_path + "/Modules/#{module_name}.swiftmodule" simulator_swiftmodule_path = simulator_framework_path + "/Modules/#{module_name}.swiftmodule" if File.exist?(simulator_swiftmodule_path) and not File.exist?(device_swiftmodule_path) FileUtils.cp_r simulator_swiftmodule_path + "/.", device_swiftmodule_path end if File.exist?(device_swiftmodule_path) and not File.exist?(simulator_swiftmodule_path) FileUtils.cp_r device_swiftmodule_path + "/.", simulator_swiftmodule_path end # combine the generated swift headers # (In xcode 10.2, the generated swift headers vary for each archs) # https://github.com/leavez/cocoapods-binary/issues/58 simulator_generated_swift_header_path = simulator_framework_path + "/Headers/#{module_name}-Swift.h" device_generated_swift_header_path = device_framework_path + "/Headers/#{module_name}-Swift.h" device_header = "" if File.exist? simulator_generated_swift_header_path device_header = File.read(device_generated_swift_header_path) end simulator_header = "" if File.exist? device_generated_swift_header_path simulator_header = File.read(device_generated_swift_header_path) end # https://github.com/Carthage/Carthage/issues/2718#issuecomment-473870461 combined_header_content = %Q{ #if TARGET_OS_SIMULATOR // merged by cocoapods-binary-bugfix #{simulator_header} #else // merged by cocoapods-binary-bugfix #{device_header} #endif // merged by cocoapods-binary-bugfix } File.write(device_generated_swift_header_path, combined_header_content.strip) # # handle the dSYM files # device_dsym = "#{device_framework_path}.dSYM" # if File.exist? device_dsym # # lipo the simulator dsym # simulator_dsym = "#{simulator_framework_path}.dSYM" # if File.exist? simulator_dsym # tmp_lipoed_binary_path = "#{output_path}/#{module_name}.draft" # lipo_log = `lipo -create -output #{tmp_lipoed_binary_path} #{device_dsym}/Contents/Resources/DWARF/#{module_name} #{simulator_dsym}/Contents/Resources/DWARF/#{module_name}` # puts lipo_log unless File.exist?(tmp_lipoed_binary_path) # FileUtils.mv tmp_lipoed_binary_path, "#{device_framework_path}.dSYM/Contents/Resources/DWARF/#{module_name}", :force => true # end # # move # FileUtils.mv device_dsym, output_path, :force => true # end # # output output_path.mkpath unless output_path.exist? FileUtils.mv device_framework_path, output_path, :force => true end |
#class_attr_accessor(symbol) ⇒ Object
attr_accessor for class variable. usage:
```
class Pod
class_attr_accessor :is_prebuild_stage
end
```
10 11 12 |
# File 'lib/cocoapods-binary-bugfix/tool/tool.rb', line 10 def class_attr_accessor(symbol) self.class.send(:attr_accessor, symbol) end |
#xcodebuild(sandbox, target, sdk = 'macosx', deployment_target = nil, other_options = []) ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/cocoapods-binary-bugfix/rome/build_framework.rb', line 127 def xcodebuild(sandbox, target, sdk='macosx', deployment_target=nil, =[]) args = %W(-project #{sandbox.project_path.realdirpath} -scheme #{target} -configuration #{CONFIGURATION} -sdk #{sdk} ) platform = PLATFORMS[sdk] args += Fourflusher::SimControl.new.destination(:oldest, platform, deployment_target) unless platform.nil? args += log = `xcodebuild #{args.join(" ")} 2>&1` exit_code = $?.exitstatus # Process::Status is_succeed = (exit_code == 0) if !is_succeed Pod::UI.puts("xcodebuild failed exitstatus:#{exit_code}") begin if log.include?('** BUILD FAILED **') # 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 else raise "shouldn't be handle by xcpretty" end rescue puts log.red end end [is_succeed, log] end |