Skip to content

Commit 18d036a

Browse files
ghostlordstarwalkerHansen
authored
update to v0.4.7 (#8)
* [GL][add ] * [GL][add `forbidden_dependency_binary!`] * update README for `forbidden_dependency_binary!` * Update README.md * [GL][merge leavez#148] * [GL][merge leavez#142] * [GL][开始开发Podfile_local功能] * [GL][Support to configure the `cocoapods-binary` plug-in separately through `BinPodfile`.] * [GL][add all_not_prebuild! configration.] * [GL][update test.rb] * [GL][update test.rb] * [GL][fix `all_not_prebuild!` bug.] * [GL][update to version: 0.4.7, update Gemfile.lock.] * [GL][update README.md]. * [GL][update README] Co-authored-by: walker <[email protected]> Co-authored-by: Hansen <[email protected]>
1 parent f677ce1 commit 18d036a

File tree

11 files changed

+176
-70
lines changed

11 files changed

+176
-70
lines changed

Gemfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
cocoapods-binary (0.4.4)
4+
cocoapods-binary (0.4.7)
55
cocoapods (>= 1.5.0, < 2.0)
66
fourflusher (~> 2.0)
77
xcpretty (~> 0.3.0)

README.md

+23-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
Forked from https://github.com/muukii/cocoapods-binary
22

3-
add `forbidden_dependency_binary!`, Prevent the automatic compilation of dependent libraries into binary as well.
3+
## Change log
4+
5+
6+
2012/09/11
7+
* Support to configure the `cocoapods-binary` plug-in separately through `BinPodfile`. [more >>](#BinPodfile)
8+
* Add `all_not_prebuild!` for prebuild. [more >>](#all_not_probuild)
9+
* Add a `test.rb` script to help you test quickly.
10+
11+
2021/03/15
12+
* add `forbidden_dependency_binary!`, Prevent the automatic compilation of dependent libraries into binary as well.
413

514
---
615

@@ -90,7 +99,20 @@ If your `Pods` folder is excluded from git, you may add `keep_source_code_for_pr
9099

91100
If bitcode is needed, add a `enable_bitcode_for_prebuilt_frameworks!` before all targets in Podfile
92101

102+
<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.
103+
104+
<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.
93105

106+
```ruby
107+
108+
# You can write the `cocoapods-binary` plugin configuration in this file.
109+
# Prevent frequent modification of `Podfile` on CI machines.
110+
111+
# e.g
112+
forbidden_dependency_binary!
113+
114+
all_not_prebuild!
115+
```
94116
#### Known Issues
95117

96118
- doesn't support watchos now

demo/BinPodfile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
# You can write the `cocoapods-binary` plugin configuration in this file.
3+
# Prevent frequent modification of `Podfile` on CI machines.
4+
5+
# e.g
6+
forbidden_dependency_binary!
7+
8+
all_not_prebuild!

demo/Gemfile.lock

+14-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: ..
33
specs:
4-
cocoapods-binary (0.4.4)
4+
cocoapods-binary (0.4.7)
55
cocoapods (>= 1.5.0, < 2.0)
66
fourflusher (~> 2.0)
77
xcpretty (~> 0.3.0)
@@ -10,12 +10,12 @@ GEM
1010
remote: https://rubygems.org/
1111
specs:
1212
CFPropertyList (3.0.3)
13-
activesupport (5.2.4.4)
13+
activesupport (5.2.6)
1414
concurrent-ruby (~> 1.0, >= 1.0.2)
1515
i18n (>= 0.7, < 2)
1616
minitest (~> 5.1)
1717
tzinfo (~> 1.1)
18-
addressable (2.7.0)
18+
addressable (2.8.0)
1919
public_suffix (>= 2.0.2, < 5.0)
2020
algoliasearch (1.27.5)
2121
httpclient (~> 2.8, >= 2.8.3)
@@ -60,37 +60,39 @@ GEM
6060
netrc (~> 0.11)
6161
cocoapods-try (1.2.0)
6262
colored2 (3.1.2)
63-
concurrent-ruby (1.1.7)
63+
concurrent-ruby (1.1.9)
6464
escape (0.0.4)
65-
ethon (0.12.0)
66-
ffi (>= 1.3.0)
67-
ffi (1.13.1)
65+
ethon (0.14.0)
66+
ffi (>= 1.15.0)
67+
ffi (1.15.3)
6868
fourflusher (2.3.1)
6969
fuzzy_match (2.0.4)
7070
gh_inspector (1.1.3)
7171
httpclient (2.8.3)
72-
i18n (1.8.5)
72+
i18n (1.8.10)
7373
concurrent-ruby (~> 1.0)
74-
json (2.3.1)
75-
minitest (5.14.2)
74+
json (2.5.1)
75+
minitest (5.14.4)
7676
molinillo (0.6.6)
7777
nanaimo (0.3.0)
7878
nap (1.1.0)
7979
netrc (0.11.0)
8080
public_suffix (4.0.6)
81+
rexml (3.2.5)
8182
rouge (2.0.7)
8283
ruby-macho (1.4.0)
8384
thread_safe (0.3.6)
8485
typhoeus (1.4.0)
8586
ethon (>= 0.9.0)
86-
tzinfo (1.2.8)
87+
tzinfo (1.2.9)
8788
thread_safe (~> 0.1)
88-
xcodeproj (1.19.0)
89+
xcodeproj (1.20.0)
8990
CFPropertyList (>= 2.3.3, < 4.0)
9091
atomos (~> 0.1.3)
9192
claide (>= 1.0.2, < 2.0)
9293
colored2 (~> 3.1)
9394
nanaimo (~> 0.3.0)
95+
rexml (~> 3.2.4)
9496
xcpretty (0.3.0)
9597
rouge (~> 2.0.7)
9698

demo/Podfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ platform :ios, '9.0'
22
plugin 'cocoapods-binary'
33

44
use_frameworks!
5-
all_binary!
6-
5+
#all_binary!
76

87
target 'demo' do
98

109
pod 'Masonry'
10+
pod 'Moya', :binary => true
1111

1212
end

demo/Podfile.lock

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,30 @@
11
PODS:
2+
- Alamofire (4.9.1)
23
- Masonry (1.1.0)
4+
- Moya (13.0.1):
5+
- Moya/Core (= 13.0.1)
6+
- Moya/Core (13.0.1):
7+
- Alamofire (~> 4.1)
8+
- Result (~> 4.1)
9+
- Result (4.1.0)
310

411
DEPENDENCIES:
512
- Masonry
13+
- Moya
614

715
SPEC REPOS:
816
trunk:
17+
- Alamofire
918
- Masonry
19+
- Moya
20+
- Result
1021

1122
SPEC CHECKSUMS:
23+
Alamofire: 85e8a02c69d6020a0d734f6054870d7ecb75cf18
1224
Masonry: 678fab65091a9290e40e2832a55e7ab731aad201
25+
Moya: f4a4b80ff2f8a4ffc208dfb31cd91636622fee6e
26+
Result: bd966fac789cc6c1563440b348ab2598cc24d5c7
1327

14-
PODFILE CHECKSUM: 5daab9dbab4736d6a1b3df2ffa8d856285c16553
28+
PODFILE CHECKSUM: 3ce0f1842cd4e2647ed42da70d44c9392b1a014d
1529

1630
COCOAPODS: 1.10.0

lib/cocoapods-binary/Integration.rb

+10-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,16 @@ def mirror_with_symlink(source, basefolder, target_folder)
8888
path_objects = hash[name]
8989
if path_objects != nil
9090
path_objects.each do |object|
91-
make_link(object.real_file_path, object.target_file_path)
91+
# make_link(object.real_file_path, object.target_file_path)
92+
# https://github.com/leavez/cocoapods-binary/pull/142
93+
target_file_path = object.target_file_path
94+
real_file_path = object.real_file_path
95+
case File.extname(real_file_path)
96+
when '.xib'
97+
real_file_path = real_file_path.sub_ext(".nib")
98+
target_file_path = target_file_path.sub(".xib", ".nib")
99+
end
100+
make_link(real_file_path, target_file_path)
92101
end
93102
end
94103
end # of for each

lib/cocoapods-binary/Main.rb

+75-50
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ def all_binary!
1212
DSL.prebuild_all = true
1313
end
1414

15+
# Disable prebuiding for all pods
16+
# it has a high priority to other binary settings
17+
def all_not_prebuild!
18+
DSL.all_not_prebuild = true
19+
end
20+
1521
# Fobidden dependency auto build to binary
1622
def forbidden_dependency_binary!
1723
DSL.forbidden_dependency_binary = true
@@ -67,6 +73,9 @@ def set_custom_xcodebuild_options_for_prebuilt_frameworks(options)
6773
class_attr_accessor :prebuild_all
6874
prebuild_all = false
6975

76+
class_attr_accessor :all_not_prebuild
77+
all_not_prebuild = false
78+
7079
class_attr_accessor :bitcode_enabled
7180
bitcode_enabled = false
7281

@@ -84,6 +93,22 @@ def set_custom_xcodebuild_options_for_prebuilt_frameworks(options)
8493
Pod::HooksManager.register('cocoapods-binary', :pre_install) do |installer_context|
8594

8695
require_relative 'helper/feature_switches'
96+
97+
# sync BinPodfile, refer to `https://github.com/tripleCC/cocoapods-bin`
98+
bin_project_root = Pod::Config.instance.project_root
99+
bin_path = File.join(bin_project_root.to_s, 'BinPodfile')
100+
next unless File.exist?(bin_path)
101+
bin_contents = File.open(bin_path, 'r:utf-8', &:read)
102+
bin_podfile = Pod::Config.instance.podfile
103+
bin_podfile.instance_eval do
104+
begin
105+
eval(bin_contents, nil, bin_path)
106+
rescue Exception => e
107+
bin_message = "Invalid `#{bin_path}` file: #{e.message}"
108+
raise Pod::DSLError.new(bin_message, bin_path, e, bin_contents)
109+
end
110+
end
111+
87112
if Pod.is_prebuild_stage
88113
next
89114
end
@@ -98,65 +123,65 @@ def set_custom_xcodebuild_options_for_prebuilt_frameworks(options)
98123
exit
99124
end
100125
end
101-
102-
103-
# -- step 1: prebuild framework ---
104-
# Execute a sperated pod install, to generate targets for building framework,
105-
# then compile them to framework files.
106-
require_relative 'helper/prebuild_sandbox'
107-
require_relative 'Prebuild'
108-
109-
Pod::UI.puts "🚀 Prebuild frameworks"
110-
111-
# Fetch original installer (which is running this pre-install hook) options,
112-
# then pass them to our installer to perform update if needed
113-
# Looks like this is the most appropriate way to figure out that something should be updated
114-
115-
update = nil
116-
repo_update = nil
117-
118-
include ObjectSpace
119-
ObjectSpace.each_object(Pod::Installer) { |installer|
120-
update = installer.update
121-
repo_update = installer.repo_update
122-
}
123-
124-
# control features
125-
Pod.is_prebuild_stage = true
126-
Pod::Podfile::DSL.enable_prebuild_patch true # enable sikpping for prebuild targets
127-
Pod::Installer.force_disable_integration true # don't integrate targets
128-
Pod::Config.force_disable_write_lockfile true # disbale write lock file for perbuild podfile
129-
Pod::Installer.disable_install_complete_message true # disable install complete message
130-
131-
# make another custom sandbox
132-
standard_sandbox = installer_context.sandbox
133-
prebuild_sandbox = Pod::PrebuildSandbox.from_standard_sandbox(standard_sandbox)
134-
135-
# get the podfile for prebuild
136-
prebuild_podfile = Pod::Podfile.from_ruby(podfile.defined_in_file)
137-
138-
# install
139-
lockfile = installer_context.lockfile
140-
binary_installer = Pod::Installer.new(prebuild_sandbox, prebuild_podfile, lockfile)
141-
142-
if binary_installer.have_exact_prebuild_cache? && !update
143-
binary_installer.install_when_cache_hit!
126+
127+
# Check prebuild enable
128+
if Pod::Podfile::DSL.all_not_prebuild # Disable prebuild
129+
Pod::UI.puts "⚠️ Disable prebuild!"
144130
else
145-
binary_installer.update = update
146-
binary_installer.repo_update = repo_update
147-
binary_installer.install!
131+
Pod::UI.puts "🚀 Prebuild frameworks"
132+
133+
# -- step 1: prebuild framework ---
134+
# Execute a sperated pod install, to generate targets for building framework,
135+
# then compile them to framework files.
136+
require_relative 'helper/prebuild_sandbox'
137+
require_relative 'Prebuild'
138+
139+
# Fetch original installer (which is running this pre-install hook) options,
140+
# then pass them to our installer to perform update if needed
141+
# Looks like this is the most appropriate way to figure out that something should be updated
142+
include ObjectSpace
143+
update = nil
144+
repo_update = nil
145+
ObjectSpace.each_object(Pod::Installer) { |installer|
146+
update = installer.update
147+
repo_update = installer.repo_update
148+
}
149+
150+
# control features
151+
Pod.is_prebuild_stage = true
152+
Pod::Podfile::DSL.enable_prebuild_patch true # enable sikpping for prebuild targets
153+
Pod::Installer.force_disable_integration true # don't integrate targets
154+
Pod::Config.force_disable_write_lockfile true # disbale write lock file for perbuild podfile
155+
Pod::Installer.disable_install_complete_message true # disable install complete message
156+
157+
# make another custom sandbox
158+
standard_sandbox = installer_context.sandbox
159+
prebuild_sandbox = Pod::PrebuildSandbox.from_standard_sandbox(standard_sandbox)
160+
161+
# get the podfile for prebuild
162+
prebuild_podfile = Pod::Podfile.from_ruby(podfile.defined_in_file)
163+
164+
# install
165+
lockfile = installer_context.lockfile
166+
binary_installer = Pod::Installer.new(prebuild_sandbox, prebuild_podfile, lockfile)
167+
168+
if binary_installer.have_exact_prebuild_cache? && !update
169+
binary_installer.install_when_cache_hit!
170+
else
171+
binary_installer.update = update
172+
binary_installer.repo_update = repo_update
173+
binary_installer.install!
174+
end
148175
end
149-
150-
176+
151177
# reset the environment
152178
Pod.is_prebuild_stage = false
153179
Pod::Installer.force_disable_integration false
154180
Pod::Podfile::DSL.enable_prebuild_patch false
155181
Pod::Config.force_disable_write_lockfile false
156182
Pod::Installer.disable_install_complete_message false
157183
Pod::UserInterface.warnings = [] # clean the warning in the prebuild step, it's duplicated.
158-
159-
184+
160185
# -- step 2: pod install ---
161186
# install
162187
Pod::UI.puts "\n"

lib/cocoapods-binary/Prebuild.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ def prebuild_frameworks!
9797
targets = root_names_to_update.map do |pod_name|
9898
tars = Pod.fast_get_targets_for_pod_name(pod_name, self.pod_targets, cache)
9999
if tars.nil? || tars.empty?
100-
raise "There's no target named (#{pod_name}) in Pod.xcodeproj.\n #{self.pod_targets.map(&:name)}" if t.nil?
100+
# https://github.com/leavez/cocoapods-binary/pull/148
101+
raise "There's no target named (#{pod_name}) in Pod.xcodeproj.\n #{self.pod_targets.map(&:name)}" if tars.nil?
101102
end
102103
tars
103104
end.flatten

lib/cocoapods-binary/gem_version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module CocoapodsBinary
2-
VERSION = "0.4.5"
2+
VERSION = "0.4.7"
33
end

test.rb

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
require 'cocoapods-binary/gem_version.rb'
2+
# build gem
3+
puts " 💫 begin build [cocoapods-binary]...\n"
4+
build_ret = %x(gem build cocoapods-binary.gemspec)
5+
6+
# build success
7+
if ( build_ret.downcase =~ /(.*)successfully(.*)/ )
8+
puts "\n✅ build [cocoapods-binary] successfully!"
9+
10+
gemFile = /cocoapods-binary-.*/.match(build_ret) # match gem file
11+
puts "\n💫 begin install #{gemFile} ...\n"
12+
install_ret = %x(sudo gem install #{gemFile}) # install gem file
13+
14+
if (install_ret.downcase =~ /(.*)successfully installed cocoapods-binary-(.*)/)
15+
Dir::chdir("demo")
16+
puts "\n✅ install gem success.\n\n💫 Begin run `Pod install`"
17+
puts "#{%x(pod install)}" # pod install
18+
else
19+
puts "❗️install #{gemFile} failed!"
20+
end
21+
else
22+
puts "❗️build [cocoapods-binary] failed!"
23+
end
24+
25+

0 commit comments

Comments
 (0)