diff --git a/Gemfile.lock b/Gemfile.lock index 9db2d0f..18c38c6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - cocoapods-binary (0.4.4) + cocoapods-binary (0.4.7) cocoapods (>= 1.5.0, < 2.0) fourflusher (~> 2.0) xcpretty (~> 0.3.0) diff --git a/README.md b/README.md index 1e3c0d9..6a9168c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,15 @@ Forked from https://github.com/muukii/cocoapods-binary -add `forbidden_dependency_binary!`, Prevent the automatic compilation of dependent libraries into binary as well. +## Change log + + +2012/09/11 +* Support to configure the `cocoapods-binary` plug-in separately through `BinPodfile`. [more >>](#BinPodfile) +* Add `all_not_prebuild!` for prebuild. [more >>](#all_not_probuild) +* Add a `test.rb` script to help you test quickly. + +2021/03/15 +* add `forbidden_dependency_binary!`, Prevent the automatic compilation of dependent libraries into binary as well. --- @@ -90,7 +99,20 @@ If your `Pods` folder is excluded from git, you may add `keep_source_code_for_pr If bitcode is needed, add a `enable_bitcode_for_prebuilt_frameworks!` before all targets in Podfile +`all_not_probuild`: If you want to disable binary for all pods, you can use `all_not_prebuild!`, it has high priority to other binary settings. + +BinPodfie: If you need to frequently modify the configuration of `cocoapods-binary`, but do not want to synchronize to the git repository, you can use `BinPodfile`, add `BinPodfile` to your `.gitignor`file. +```ruby + +# You can write the `cocoapods-binary` plugin configuration in this file. +# Prevent frequent modification of `Podfile` on CI machines. + +# e.g +forbidden_dependency_binary! + +all_not_prebuild! +``` #### Known Issues - doesn't support watchos now diff --git a/demo/BinPodfile b/demo/BinPodfile new file mode 100644 index 0000000..f051b02 --- /dev/null +++ b/demo/BinPodfile @@ -0,0 +1,8 @@ + +# You can write the `cocoapods-binary` plugin configuration in this file. +# Prevent frequent modification of `Podfile` on CI machines. + +# e.g +forbidden_dependency_binary! + +all_not_prebuild! \ No newline at end of file diff --git a/demo/Gemfile.lock b/demo/Gemfile.lock index 7c0bc1d..af32a7f 100644 --- a/demo/Gemfile.lock +++ b/demo/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - cocoapods-binary (0.4.4) + cocoapods-binary (0.4.7) cocoapods (>= 1.5.0, < 2.0) fourflusher (~> 2.0) xcpretty (~> 0.3.0) @@ -10,12 +10,12 @@ GEM remote: https://rubygems.org/ specs: CFPropertyList (3.0.3) - activesupport (5.2.4.4) + activesupport (5.2.6) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) - addressable (2.7.0) + addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) algoliasearch (1.27.5) httpclient (~> 2.8, >= 2.8.3) @@ -60,37 +60,39 @@ GEM netrc (~> 0.11) cocoapods-try (1.2.0) colored2 (3.1.2) - concurrent-ruby (1.1.7) + concurrent-ruby (1.1.9) escape (0.0.4) - ethon (0.12.0) - ffi (>= 1.3.0) - ffi (1.13.1) + ethon (0.14.0) + ffi (>= 1.15.0) + ffi (1.15.3) fourflusher (2.3.1) fuzzy_match (2.0.4) gh_inspector (1.1.3) httpclient (2.8.3) - i18n (1.8.5) + i18n (1.8.10) concurrent-ruby (~> 1.0) - json (2.3.1) - minitest (5.14.2) + json (2.5.1) + minitest (5.14.4) molinillo (0.6.6) nanaimo (0.3.0) nap (1.1.0) netrc (0.11.0) public_suffix (4.0.6) + rexml (3.2.5) rouge (2.0.7) ruby-macho (1.4.0) thread_safe (0.3.6) typhoeus (1.4.0) ethon (>= 0.9.0) - tzinfo (1.2.8) + tzinfo (1.2.9) thread_safe (~> 0.1) - xcodeproj (1.19.0) + xcodeproj (1.20.0) CFPropertyList (>= 2.3.3, < 4.0) atomos (~> 0.1.3) claide (>= 1.0.2, < 2.0) colored2 (~> 3.1) nanaimo (~> 0.3.0) + rexml (~> 3.2.4) xcpretty (0.3.0) rouge (~> 2.0.7) diff --git a/demo/Podfile b/demo/Podfile index e91f600..2a5f26b 100644 --- a/demo/Podfile +++ b/demo/Podfile @@ -2,11 +2,11 @@ platform :ios, '9.0' plugin 'cocoapods-binary' use_frameworks! -all_binary! - +#all_binary! target 'demo' do pod 'Masonry' + pod 'Moya', :binary => true end diff --git a/demo/Podfile.lock b/demo/Podfile.lock index f58bbb7..6b7a1c3 100644 --- a/demo/Podfile.lock +++ b/demo/Podfile.lock @@ -1,16 +1,30 @@ PODS: + - Alamofire (4.9.1) - Masonry (1.1.0) + - Moya (13.0.1): + - Moya/Core (= 13.0.1) + - Moya/Core (13.0.1): + - Alamofire (~> 4.1) + - Result (~> 4.1) + - Result (4.1.0) DEPENDENCIES: - Masonry + - Moya SPEC REPOS: trunk: + - Alamofire - Masonry + - Moya + - Result SPEC CHECKSUMS: + Alamofire: 85e8a02c69d6020a0d734f6054870d7ecb75cf18 Masonry: 678fab65091a9290e40e2832a55e7ab731aad201 + Moya: f4a4b80ff2f8a4ffc208dfb31cd91636622fee6e + Result: bd966fac789cc6c1563440b348ab2598cc24d5c7 -PODFILE CHECKSUM: 5daab9dbab4736d6a1b3df2ffa8d856285c16553 +PODFILE CHECKSUM: 3ce0f1842cd4e2647ed42da70d44c9392b1a014d COCOAPODS: 1.10.0 diff --git a/lib/cocoapods-binary/Integration.rb b/lib/cocoapods-binary/Integration.rb index 660b013..0f39f87 100644 --- a/lib/cocoapods-binary/Integration.rb +++ b/lib/cocoapods-binary/Integration.rb @@ -88,7 +88,16 @@ def mirror_with_symlink(source, basefolder, target_folder) path_objects = hash[name] if path_objects != nil path_objects.each do |object| - make_link(object.real_file_path, object.target_file_path) + # make_link(object.real_file_path, object.target_file_path) + # https://github.com/leavez/cocoapods-binary/pull/142 + target_file_path = object.target_file_path + real_file_path = object.real_file_path + case File.extname(real_file_path) + when '.xib' + real_file_path = real_file_path.sub_ext(".nib") + target_file_path = target_file_path.sub(".xib", ".nib") + end + make_link(real_file_path, target_file_path) end end end # of for each diff --git a/lib/cocoapods-binary/Main.rb b/lib/cocoapods-binary/Main.rb index 33e193d..edb57cb 100644 --- a/lib/cocoapods-binary/Main.rb +++ b/lib/cocoapods-binary/Main.rb @@ -12,6 +12,12 @@ def all_binary! DSL.prebuild_all = true end + # Disable prebuiding for all pods + # it has a high priority to other binary settings + def all_not_prebuild! + DSL.all_not_prebuild = true + end + # Fobidden dependency auto build to binary def forbidden_dependency_binary! DSL.forbidden_dependency_binary = true @@ -67,6 +73,9 @@ def set_custom_xcodebuild_options_for_prebuilt_frameworks(options) class_attr_accessor :prebuild_all prebuild_all = false + class_attr_accessor :all_not_prebuild + all_not_prebuild = false + class_attr_accessor :bitcode_enabled bitcode_enabled = false @@ -84,6 +93,22 @@ def set_custom_xcodebuild_options_for_prebuilt_frameworks(options) Pod::HooksManager.register('cocoapods-binary', :pre_install) do |installer_context| require_relative 'helper/feature_switches' + + # sync BinPodfile, refer to `https://github.com/tripleCC/cocoapods-bin` + bin_project_root = Pod::Config.instance.project_root + bin_path = File.join(bin_project_root.to_s, 'BinPodfile') + next unless File.exist?(bin_path) + bin_contents = File.open(bin_path, 'r:utf-8', &:read) + bin_podfile = Pod::Config.instance.podfile + bin_podfile.instance_eval do + begin + eval(bin_contents, nil, bin_path) + rescue Exception => e + bin_message = "Invalid `#{bin_path}` file: #{e.message}" + raise Pod::DSLError.new(bin_message, bin_path, e, bin_contents) + end + end + if Pod.is_prebuild_stage next end @@ -98,56 +123,57 @@ def set_custom_xcodebuild_options_for_prebuilt_frameworks(options) exit end end - - - # -- step 1: prebuild framework --- - # Execute a sperated pod install, to generate targets for building framework, - # then compile them to framework files. - require_relative 'helper/prebuild_sandbox' - require_relative 'Prebuild' - - Pod::UI.puts "🚀 Prebuild frameworks" - - # Fetch original installer (which is running this pre-install hook) options, - # then pass them to our installer to perform update if needed - # Looks like this is the most appropriate way to figure out that something should be updated - - update = nil - repo_update = nil - - include ObjectSpace - ObjectSpace.each_object(Pod::Installer) { |installer| - update = installer.update - repo_update = installer.repo_update - } - - # control features - Pod.is_prebuild_stage = true - Pod::Podfile::DSL.enable_prebuild_patch true # enable sikpping for prebuild targets - Pod::Installer.force_disable_integration true # don't integrate targets - Pod::Config.force_disable_write_lockfile true # disbale write lock file for perbuild podfile - Pod::Installer.disable_install_complete_message true # disable install complete message - - # make another custom sandbox - standard_sandbox = installer_context.sandbox - prebuild_sandbox = Pod::PrebuildSandbox.from_standard_sandbox(standard_sandbox) - - # get the podfile for prebuild - prebuild_podfile = Pod::Podfile.from_ruby(podfile.defined_in_file) - - # install - lockfile = installer_context.lockfile - binary_installer = Pod::Installer.new(prebuild_sandbox, prebuild_podfile, lockfile) - - if binary_installer.have_exact_prebuild_cache? && !update - binary_installer.install_when_cache_hit! + + # Check prebuild enable + if Pod::Podfile::DSL.all_not_prebuild # Disable prebuild + Pod::UI.puts "⚠️ Disable prebuild!" else - binary_installer.update = update - binary_installer.repo_update = repo_update - binary_installer.install! + Pod::UI.puts "🚀 Prebuild frameworks" + + # -- step 1: prebuild framework --- + # Execute a sperated pod install, to generate targets for building framework, + # then compile them to framework files. + require_relative 'helper/prebuild_sandbox' + require_relative 'Prebuild' + + # Fetch original installer (which is running this pre-install hook) options, + # then pass them to our installer to perform update if needed + # Looks like this is the most appropriate way to figure out that something should be updated + include ObjectSpace + update = nil + repo_update = nil + ObjectSpace.each_object(Pod::Installer) { |installer| + update = installer.update + repo_update = installer.repo_update + } + + # control features + Pod.is_prebuild_stage = true + Pod::Podfile::DSL.enable_prebuild_patch true # enable sikpping for prebuild targets + Pod::Installer.force_disable_integration true # don't integrate targets + Pod::Config.force_disable_write_lockfile true # disbale write lock file for perbuild podfile + Pod::Installer.disable_install_complete_message true # disable install complete message + + # make another custom sandbox + standard_sandbox = installer_context.sandbox + prebuild_sandbox = Pod::PrebuildSandbox.from_standard_sandbox(standard_sandbox) + + # get the podfile for prebuild + prebuild_podfile = Pod::Podfile.from_ruby(podfile.defined_in_file) + + # install + lockfile = installer_context.lockfile + binary_installer = Pod::Installer.new(prebuild_sandbox, prebuild_podfile, lockfile) + + if binary_installer.have_exact_prebuild_cache? && !update + binary_installer.install_when_cache_hit! + else + binary_installer.update = update + binary_installer.repo_update = repo_update + binary_installer.install! + end end - - + # reset the environment Pod.is_prebuild_stage = false Pod::Installer.force_disable_integration false @@ -155,8 +181,7 @@ def set_custom_xcodebuild_options_for_prebuilt_frameworks(options) Pod::Config.force_disable_write_lockfile false Pod::Installer.disable_install_complete_message false Pod::UserInterface.warnings = [] # clean the warning in the prebuild step, it's duplicated. - - + # -- step 2: pod install --- # install Pod::UI.puts "\n" diff --git a/lib/cocoapods-binary/Prebuild.rb b/lib/cocoapods-binary/Prebuild.rb index 98e3449..6f3cb79 100644 --- a/lib/cocoapods-binary/Prebuild.rb +++ b/lib/cocoapods-binary/Prebuild.rb @@ -97,7 +97,8 @@ def prebuild_frameworks! targets = root_names_to_update.map do |pod_name| tars = Pod.fast_get_targets_for_pod_name(pod_name, self.pod_targets, cache) if tars.nil? || tars.empty? - raise "There's no target named (#{pod_name}) in Pod.xcodeproj.\n #{self.pod_targets.map(&:name)}" if t.nil? + # https://github.com/leavez/cocoapods-binary/pull/148 + raise "There's no target named (#{pod_name}) in Pod.xcodeproj.\n #{self.pod_targets.map(&:name)}" if tars.nil? end tars end.flatten diff --git a/lib/cocoapods-binary/gem_version.rb b/lib/cocoapods-binary/gem_version.rb index 2f2cd56..0b21f91 100644 --- a/lib/cocoapods-binary/gem_version.rb +++ b/lib/cocoapods-binary/gem_version.rb @@ -1,3 +1,3 @@ module CocoapodsBinary - VERSION = "0.4.5" + VERSION = "0.4.7" end diff --git a/test.rb b/test.rb new file mode 100644 index 0000000..31b47a7 --- /dev/null +++ b/test.rb @@ -0,0 +1,25 @@ +require 'cocoapods-binary/gem_version.rb' +# build gem +puts " 💫 begin build [cocoapods-binary]...\n" +build_ret = %x(gem build cocoapods-binary.gemspec) + +# build success +if ( build_ret.downcase =~ /(.*)successfully(.*)/ ) + puts "\n✅ build [cocoapods-binary] successfully!" + + gemFile = /cocoapods-binary-.*/.match(build_ret) # match gem file + puts "\n💫 begin install #{gemFile} ...\n" + install_ret = %x(sudo gem install #{gemFile}) # install gem file + + if (install_ret.downcase =~ /(.*)successfully installed cocoapods-binary-(.*)/) + Dir::chdir("demo") + puts "\n✅ install gem success.\n\n💫 Begin run `Pod install`" + puts "#{%x(pod install)}" # pod install + else + puts "❗️install #{gemFile} failed!" + end +else + puts "❗️build [cocoapods-binary] failed!" +end + +