Skip to content

Commit effa191

Browse files
authored
Merge pull request #1 from AliSoftware/master
Fix The deployment target used to find the right simulator to compile the binaries
2 parents 5d7c159 + aabc1a5 commit effa191

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

lib/cocoapods-binary/Prebuild.rb

+9-2
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def prebuild_frameworks!
9797
targets = root_names_to_update.map do |pod_name|
9898
tars = Pod.fast_get_targets_for_pod_name(pod_name, self.pod_targets, cache)
9999
if tars.nil? || tars.empty?
100-
raise "There's no target named (#{pod_name}) in Pod.xcodeproj.\n #{self.pod_targets.map(&:name)}" if t.nil?
100+
raise "There's no target named (#{pod_name}) in Pods.xcodeproj.\n #{self.pod_targets.map(&:name)}" if t.nil?
101101
end
102102
tars
103103
end.flatten
@@ -123,7 +123,14 @@ def prebuild_frameworks!
123123

124124
output_path = sandbox.framework_folder_path_for_target_name(target.name)
125125
output_path.mkpath unless output_path.exist?
126-
Pod::Prebuild.build(sandbox_path, target, output_path, bitcode_enabled, Podfile::DSL.custom_build_options, Podfile::DSL.custom_build_options_simulator)
126+
127+
min_deployment_target = aggregate_targets
128+
.select { |t| t.pod_targets.include?(target) }
129+
.map(&:platform)
130+
.map(&:deployment_target)
131+
.max
132+
133+
Pod::Prebuild.build(sandbox_path, target, min_deployment_target, output_path, bitcode_enabled, Podfile::DSL.custom_build_options, Podfile::DSL.custom_build_options_simulator)
127134

128135
# save the resource paths for later installing
129136
if target.static_framework? and !target.resource_paths.empty?

lib/cocoapods-binary/helper/target_checker.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def self.check_one_pod_should_have_only_one_target(prebuilt_targets)
1414
raw_names = targets_have_different_platforms.map(&:name)
1515
message = "Oops, you came across a limitation of cocoapods-binary.
1616
17-
The plugin requires that one pod should have ONLY ONE target in the 'Pod.xcodeproj'. There are mainly 2 situations \
17+
The plugin requires that one pod should have ONLY ONE target in the 'Pods.xcodeproj'. There are mainly 2 situations \
1818
causing this problem:
1919
2020
1. One pod integrates in 2 or more different platforms' targets. e.g.

lib/cocoapods-binary/rome/build_framework.rb

+6-7
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@ def build_for_iosish_platform(sandbox,
1414
build_dir,
1515
output_path,
1616
target,
17+
deployment_target,
1718
device,
1819
simulator,
1920
bitcode_enabled,
2021
custom_build_options = [], # Array<String>
2122
custom_build_options_simulator = [] # Array<String>
2223
)
23-
24-
deployment_target = target.platform.deployment_target.to_s
2524

2625
target_label = target.label # name with platform if it's used in multiple platforms
2726
Pod::UI.puts "Prebuilding #{target_label}..."
@@ -51,7 +50,7 @@ def build_for_iosish_platform(sandbox,
5150
# combine the binaries
5251
tmp_lipoed_binary_path = "#{build_dir}/#{target_name}"
5352
lipo_log = `lipo -create -output #{tmp_lipoed_binary_path} #{device_binary} #{simulator_binary}`
54-
puts lipo_log unless File.exist?(tmp_lipoed_binary_path)
53+
Pod::UI.puts lipo_log unless File.exist?(tmp_lipoed_binary_path)
5554
FileUtils.mv tmp_lipoed_binary_path, device_binary, :force => true
5655

5756
# collect the swiftmodule file for various archs.
@@ -124,10 +123,10 @@ def xcodebuild(sandbox, target, sdk='macosx', deployment_target=nil, other_optio
124123
printer.pretty_print(line)
125124
end
126125
else
127-
raise "shouldn't be handle by xcpretty"
126+
raise "shouldn't be handled by xcpretty"
128127
end
129128
rescue
130-
puts log.red
129+
Pod::UI.puts log.red
131130
end
132131
end
133132
[is_succeed, log]
@@ -149,7 +148,7 @@ class Prebuild
149148
# [Pathname] output_path
150149
# output path for generated frameworks
151150
#
152-
def self.build(sandbox_root_path, target, output_path, bitcode_enabled = false, custom_build_options=[], custom_build_options_simulator=[])
151+
def self.build(sandbox_root_path, target, min_deployment_target, output_path, bitcode_enabled = false, custom_build_options=[], custom_build_options_simulator=[])
153152

154153
return if target.nil?
155154

@@ -159,7 +158,7 @@ def self.build(sandbox_root_path, target, output_path, bitcode_enabled = false,
159158

160159
# -- build the framework
161160
case target.platform.name
162-
when :ios then build_for_iosish_platform(sandbox, build_dir, output_path, target, 'iphoneos', 'iphonesimulator', bitcode_enabled, custom_build_options, custom_build_options_simulator)
161+
when :ios then build_for_iosish_platform(sandbox, build_dir, output_path, target, min_deployment_target, 'iphoneos', 'iphonesimulator', bitcode_enabled, custom_build_options, custom_build_options_simulator)
163162
when :osx then xcodebuild(sandbox, target.label, 'macosx', nil, custom_build_options)
164163
# when :tvos then build_for_iosish_platform(sandbox, build_dir, target, 'appletvos', 'appletvsimulator')
165164
when :watchos then build_for_iosish_platform(sandbox, build_dir, output_path, target, 'watchos', 'watchsimulator', true, custom_build_options, custom_build_options_simulator)

0 commit comments

Comments
 (0)