Skip to content

Commit 5a10c33

Browse files
authored
Merge pull request #67 from leavez/log
Add more detail log for one pod has multiple targets
2 parents e2b96c4 + 398147c commit 5a10c33

File tree

3 files changed

+68
-14
lines changed

3 files changed

+68
-14
lines changed

lib/cocoapods-binary/Integration.rb

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
require_relative 'helper/feature_switches'
33
require_relative 'helper/prebuild_sandbox'
44
require_relative 'helper/passer'
5+
require_relative 'helper/target_checker'
56

67

78
# NOTE:
@@ -128,18 +129,12 @@ def remove_target_files_if_needed
128129
# call original
129130
old_method2.bind(self).()
130131

132+
# check the pods
133+
# Although we have did it in prebuild stage, it's not sufficient.
134+
# Same pod may appear in another target in form of source code.
135+
Prebuild.check_one_pod_should_have_only_one_target(self.prebuild_pod_targets)
131136

132-
# check the prebuilt targets
133-
targets = self.prebuild_pod_targets
134-
targets_have_different_platforms = targets.select {|t| t.pod_name != t.name }
135-
136-
if targets_have_different_platforms.count > 0
137-
names = targets_have_different_platforms.map(&:pod_name)
138-
STDERR.puts "[!] Binary doesn't support pods who integrate in 2 or more platforms simultaneously: #{names}".red
139-
exit
140-
end
141-
142-
137+
#
143138
specs = self.analysis_result.specifications
144139
prebuilt_specs = (specs.select do |spec|
145140
self.prebuild_pod_names.include? spec.root.name

lib/cocoapods-binary/Prebuild.rb

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
require_relative 'rome/build_framework'
22
require_relative 'helper/passer'
3+
require_relative 'helper/target_checker'
4+
35

46
# patch prebuild ability
57
module Pod
@@ -67,6 +69,10 @@ def install_when_cache_hit!
6769
# Build the needed framework files
6870
def prebuild_frameworks!
6971

72+
# check
73+
# give a early warning, instead of after compiling all the pods
74+
Prebuild.check_one_pod_should_have_only_one_target(self.pod_targets)
75+
7076
# build options
7177
sandbox_path = sandbox.root
7278
existed_framework_folder = sandbox.generate_framework_path
@@ -98,7 +104,9 @@ def prebuild_frameworks!
98104
sum
99105
end
100106
targets = root_names_to_update.map do |root_name|
101-
name_to_target_hash[root_name]
107+
t = name_to_target_hash[root_name]
108+
raise "There's no target named (#{root_name}) in Pod.xcodeproj.\n #{name_to_target_hash.keys}" if t.nil?
109+
t
102110
end || []
103111

104112
# add the dendencies
@@ -111,12 +119,14 @@ def prebuild_frameworks!
111119
targets = targets.reject {|pod_target| sandbox.local?(pod_target.pod_name) }
112120

113121

114-
115122
# build!
116123
Pod::UI.puts "Prebuild frameworks (total #{targets.count})"
117124
Pod::Prebuild.remove_build_dir(sandbox_path)
118125
targets.each do |target|
119-
next unless target.should_build?
126+
if !target.should_build?
127+
UI.puts "Prebuilding #{target.label}"
128+
next
129+
end
120130

121131
output_path = sandbox.framework_folder_path_for_pod_name(target.name)
122132
output_path.mkpath unless output_path.exist?
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
2+
module Pod
3+
class Prebuild
4+
5+
# Check the targets, for the current limitation of the plugin
6+
#
7+
# @param [Array<PodTarget>] prebuilt_targets
8+
def self.check_one_pod_should_have_only_one_target(prebuilt_targets)
9+
10+
targets_have_different_platforms = prebuilt_targets.select {|t| t.pod_name != t.name }
11+
12+
if targets_have_different_platforms.count > 0
13+
names = targets_have_different_platforms.map(&:pod_name)
14+
raw_names = targets_have_different_platforms.map(&:name)
15+
message = "Oops, you came across a limitation of cocoapods-binary.
16+
17+
The plugin requires that one pod should have ONLY ONE target in the 'Pod.xcodeproj'. There are mainly 2 situations \
18+
causing this problem:
19+
20+
1. One pod integrates in 2 or more different platforms' targets. e.g.
21+
```
22+
target 'iphoneApp' do
23+
pod 'A', :binary => true
24+
end
25+
target 'watchApp' do
26+
pod 'A'
27+
end
28+
```
29+
30+
2. Use different subspecs in multiple targets. e.g.
31+
```
32+
target 'iphoneApp' do
33+
pod 'A/core'
34+
pod 'A/network'
35+
end
36+
target 'iphoneAppTest' do
37+
pod 'A/core'
38+
end
39+
```
40+
41+
Related pods: #{names}, target names: #{raw_names}
42+
"
43+
raise Informative, message
44+
end
45+
end
46+
47+
48+
end
49+
end

0 commit comments

Comments
 (0)