From 16f17faead39ba52a5129d1986c38756ecae5be1 Mon Sep 17 00:00:00 2001 From: leavez Date: Tue, 23 Apr 2019 22:53:51 +0800 Subject: [PATCH 1/5] add log for skipped prebuilding pod --- lib/cocoapods-binary/Prebuild.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/cocoapods-binary/Prebuild.rb b/lib/cocoapods-binary/Prebuild.rb index e5a69c5..f030306 100644 --- a/lib/cocoapods-binary/Prebuild.rb +++ b/lib/cocoapods-binary/Prebuild.rb @@ -116,7 +116,10 @@ def prebuild_frameworks! 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? From d6c9c13a140ca096d5a0ed3b7f0c85414111a213 Mon Sep 17 00:00:00 2001 From: leavez Date: Tue, 23 Apr 2019 23:20:54 +0800 Subject: [PATCH 2/5] add log for target missing in Pod.xcproj --- lib/cocoapods-binary/Prebuild.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/cocoapods-binary/Prebuild.rb b/lib/cocoapods-binary/Prebuild.rb index f030306..cf35b13 100644 --- a/lib/cocoapods-binary/Prebuild.rb +++ b/lib/cocoapods-binary/Prebuild.rb @@ -98,7 +98,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 From 614915ebcd688e7b7652e5cf3bb7ec804b161ccc Mon Sep 17 00:00:00 2001 From: leavez Date: Wed, 24 Apr 2019 02:12:10 +0800 Subject: [PATCH 3/5] add a early pods checking and enrich the log --- lib/cocoapods-binary/Integration.rb | 17 +++---- lib/cocoapods-binary/Prebuild.rb | 5 ++ lib/cocoapods-binary/helper/target_checker.rb | 49 +++++++++++++++++++ 3 files changed, 60 insertions(+), 11 deletions(-) create mode 100644 lib/cocoapods-binary/helper/target_checker.rb diff --git a/lib/cocoapods-binary/Integration.rb b/lib/cocoapods-binary/Integration.rb index 8a9a75b..7f5e516 100644 --- a/lib/cocoapods-binary/Integration.rb +++ b/lib/cocoapods-binary/Integration.rb @@ -2,6 +2,7 @@ require_relative 'helper/feature_switches' require_relative 'helper/prebuild_sandbox' require_relative 'helper/passer' +require_relative 'helper/target_checker' # NOTE: @@ -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(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 diff --git a/lib/cocoapods-binary/Prebuild.rb b/lib/cocoapods-binary/Prebuild.rb index cf35b13..c27b9bd 100644 --- a/lib/cocoapods-binary/Prebuild.rb +++ b/lib/cocoapods-binary/Prebuild.rb @@ -1,5 +1,7 @@ require_relative 'rome/build_framework' require_relative 'helper/passer' +require_relative 'helper/target_checker' + # patch prebuild ability module Pod @@ -112,6 +114,9 @@ def prebuild_frameworks! targets = targets.reject {|pod_target| sandbox.local?(pod_target.pod_name) } + # check + # give a early warning, instead of after compiling all the pods + Prebuild.check_one_pod_should_have_only_one_target(targets) # build! diff --git a/lib/cocoapods-binary/helper/target_checker.rb b/lib/cocoapods-binary/helper/target_checker.rb new file mode 100644 index 0000000..7d90a1f --- /dev/null +++ b/lib/cocoapods-binary/helper/target_checker.rb @@ -0,0 +1,49 @@ + +module Pod + class Prebuild + + # Check the targets, for the current limitation of the plugin + # + # @param [Array] 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 \ No newline at end of file From dc3b3691b67eefccad929bd1139ab019017abbbb Mon Sep 17 00:00:00 2001 From: leavez Date: Wed, 24 Apr 2019 02:34:38 +0800 Subject: [PATCH 4/5] fix --- lib/cocoapods-binary/Integration.rb | 2 +- lib/cocoapods-binary/Prebuild.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/cocoapods-binary/Integration.rb b/lib/cocoapods-binary/Integration.rb index 7f5e516..8778f2b 100644 --- a/lib/cocoapods-binary/Integration.rb +++ b/lib/cocoapods-binary/Integration.rb @@ -132,7 +132,7 @@ def remove_target_files_if_needed # 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(targets) + Prebuild.check_one_pod_should_have_only_one_target(self.prebuild_pod_targets) # specs = self.analysis_result.specifications diff --git a/lib/cocoapods-binary/Prebuild.rb b/lib/cocoapods-binary/Prebuild.rb index c27b9bd..9a9b0e3 100644 --- a/lib/cocoapods-binary/Prebuild.rb +++ b/lib/cocoapods-binary/Prebuild.rb @@ -116,8 +116,8 @@ def prebuild_frameworks! # check # give a early warning, instead of after compiling all the pods - Prebuild.check_one_pod_should_have_only_one_target(targets) + Prebuild.check_one_pod_should_have_only_one_target(self.pod_targets) # build! Pod::UI.puts "Prebuild frameworks (total #{targets.count})" From 398147ca5f21a4d24f8452f7fd70044241e58da6 Mon Sep 17 00:00:00 2001 From: leavez Date: Wed, 24 Apr 2019 02:35:54 +0800 Subject: [PATCH 5/5] move check earlier --- lib/cocoapods-binary/Prebuild.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/cocoapods-binary/Prebuild.rb b/lib/cocoapods-binary/Prebuild.rb index 9a9b0e3..9123a5f 100644 --- a/lib/cocoapods-binary/Prebuild.rb +++ b/lib/cocoapods-binary/Prebuild.rb @@ -69,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 @@ -114,10 +118,6 @@ def prebuild_frameworks! targets = targets.reject {|pod_target| sandbox.local?(pod_target.pod_name) } - # 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! Pod::UI.puts "Prebuild frameworks (total #{targets.count})"