Skip to content

update to v0.4.7 #8

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

Merged
merged 17 commits into from
Oct 5, 2021
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
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.

---

Expand Down Expand Up @@ -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

<span id='all_not_probuild'>`all_not_probuild`: </span>If you want to disable binary for all pods, you can use `all_not_prebuild!`, it has high priority to other binary settings.

<span id="BinPodfile">BinPodfie: </span>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
Expand Down
8 changes: 8 additions & 0 deletions demo/BinPodfile
Original file line number Diff line number Diff line change
@@ -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!
26 changes: 14 additions & 12 deletions demo/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions demo/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 15 additions & 1 deletion demo/Podfile.lock
Original file line number Diff line number Diff line change
@@ -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
11 changes: 10 additions & 1 deletion lib/cocoapods-binary/Integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
125 changes: 75 additions & 50 deletions lib/cocoapods-binary/Main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand All @@ -98,65 +123,65 @@ 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
Pod::Podfile::DSL.enable_prebuild_patch false
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"
Expand Down
3 changes: 2 additions & 1 deletion lib/cocoapods-binary/Prebuild.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/cocoapods-binary/gem_version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module CocoapodsBinary
VERSION = "0.4.5"
VERSION = "0.4.7"
end
25 changes: 25 additions & 0 deletions test.rb
Original file line number Diff line number Diff line change
@@ -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