Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more detail log for one pod has multiple targets #67

Merged
merged 5 commits into from
Apr 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions lib/cocoapods-binary/Integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require_relative 'helper/feature_switches'
require_relative 'helper/prebuild_sandbox'
require_relative 'helper/passer'
require_relative 'helper/target_checker'


# NOTE:
Expand Down Expand Up @@ -128,18 +129,12 @@ def remove_target_files_if_needed
# call original
old_method2.bind(self).()

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

# check the prebuilt targets
targets = self.prebuild_pod_targets
targets_have_different_platforms = targets.select {|t| t.pod_name != t.name }

if targets_have_different_platforms.count > 0
names = targets_have_different_platforms.map(&:pod_name)
STDERR.puts "[!] Binary doesn't support pods who integrate in 2 or more platforms simultaneously: #{names}".red
exit
end


#
specs = self.analysis_result.specifications
prebuilt_specs = (specs.select do |spec|
self.prebuild_pod_names.include? spec.root.name
Expand Down
16 changes: 13 additions & 3 deletions lib/cocoapods-binary/Prebuild.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
require_relative 'rome/build_framework'
require_relative 'helper/passer'
require_relative 'helper/target_checker'


# patch prebuild ability
module Pod
Expand Down Expand Up @@ -67,6 +69,10 @@ def install_when_cache_hit!
# Build the needed framework files
def prebuild_frameworks!

# check
# give a early warning, instead of after compiling all the pods
Prebuild.check_one_pod_should_have_only_one_target(self.pod_targets)

# build options
sandbox_path = sandbox.root
existed_framework_folder = sandbox.generate_framework_path
Expand Down Expand Up @@ -98,7 +104,9 @@ def prebuild_frameworks!
sum
end
targets = root_names_to_update.map do |root_name|
name_to_target_hash[root_name]
t = name_to_target_hash[root_name]
raise "There's no target named (#{root_name}) in Pod.xcodeproj.\n #{name_to_target_hash.keys}" if t.nil?
t
end || []

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



# build!
Pod::UI.puts "Prebuild frameworks (total #{targets.count})"
Pod::Prebuild.remove_build_dir(sandbox_path)
targets.each do |target|
next unless target.should_build?
if !target.should_build?
UI.puts "Prebuilding #{target.label}"
next
end

output_path = sandbox.framework_folder_path_for_pod_name(target.name)
output_path.mkpath unless output_path.exist?
Expand Down
49 changes: 49 additions & 0 deletions lib/cocoapods-binary/helper/target_checker.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

module Pod
class Prebuild

# Check the targets, for the current limitation of the plugin
#
# @param [Array<PodTarget>] prebuilt_targets
def self.check_one_pod_should_have_only_one_target(prebuilt_targets)

targets_have_different_platforms = prebuilt_targets.select {|t| t.pod_name != t.name }

if targets_have_different_platforms.count > 0
names = targets_have_different_platforms.map(&:pod_name)
raw_names = targets_have_different_platforms.map(&:name)
message = "Oops, you came across a limitation of cocoapods-binary.

The plugin requires that one pod should have ONLY ONE target in the 'Pod.xcodeproj'. There are mainly 2 situations \
causing this problem:

1. One pod integrates in 2 or more different platforms' targets. e.g.
```
target 'iphoneApp' do
pod 'A', :binary => true
end
target 'watchApp' do
pod 'A'
end
```

2. Use different subspecs in multiple targets. e.g.
```
target 'iphoneApp' do
pod 'A/core'
pod 'A/network'
end
target 'iphoneAppTest' do
pod 'A/core'
end
```

Related pods: #{names}, target names: #{raw_names}
"
raise Informative, message
end
end


end
end