cocoapods-binary-bel 0.5.1 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ff8183174797ebc162d61d086a2775688c82e76bcbe894435595948854eab0a0
4
- data.tar.gz: 5b5fa7f18e0a0474562456166226d518e84f63ec3ba1e2b634901e0fdf085854
3
+ metadata.gz: 43eafcaf495ad77650ab39ac89ec3c39f0d5b4c189c648ab5b9c10f7fb97c4fd
4
+ data.tar.gz: 0cf9685573422c38b7f0d02bcd216b0b7f368e648815e0a51be59ff17ae1afd6
5
5
  SHA512:
6
- metadata.gz: 32c7cc708291d9500d17fda16d45bda650dc1f2d90bf806978cd8acb36de365dda764af0f11338447e2edad8d53ae618a91503f60a8619d3bed35e864d2ffad3
7
- data.tar.gz: faa283aeb42a00bfc7c755f551fab66f2cac8a5a1dd8124309408cb2bb7566f08ea2de9aaa2c93f93b83c5da5abb4a3d2959120ef67c7b135831308bdca20e98
6
+ metadata.gz: d8b6e436a575e2cfa1a79b4044cc97386ec3b30f0049743c1d1b98041b412e4a06012b6c0e16d9ffabe0a98dd9028ac6d263fcb5715b6f9cf17207a45b0166f4
7
+ data.tar.gz: e124121fd3991bc78971dcb445c6e2555fbebbc39640c9ed81ef52e1d0babe4428f35516b6174561f6ece8898b7f90fe86112a514a26acc2d40ad51ef6145d77
data/README.md CHANGED
@@ -25,6 +25,8 @@ It will compile the source code of pods during the pod install process, and make
25
25
 
26
26
  #### Under the hood
27
27
 
28
+ blog: https://juejin.cn/post/7035628418972516360
29
+
28
30
  ( You could leave this paragraph for further reading, and try it now. )
29
31
 
30
32
  The plugin will do a separated completed 'Pod install' in the standard pre-install hook. But we filter the pods by the flag in Podfile here. Then build frameworks with this generated project by using xcodebuild. Store the frameworks in `Pods/_Prebuild` and save the manifest.lock file for the next pod install.
@@ -33,8 +35,7 @@ Then in the flowing normal install process, we hook the integration functions to
33
35
 
34
36
  ## Installation
35
37
 
36
- ## 编译方法
37
- sudo gem build cocoapods-binary-bel.gemspec && sudo gem install cocoapods-binary-bel-0.4.8.gem
38
+ sudo gem install cocoapods-binary-bel
38
39
 
39
40
  ## Usage
40
41
 
@@ -49,10 +50,12 @@ target "HP" do
49
50
  end
50
51
  ```
51
52
 
52
- - Add `plugin 'cocoapods-binary'` in the head of Podfile
53
+ - Add `plugin 'cocoapods-binary-bel'` in the head of Podfile
53
54
  - Add `:binary => true` as a option of one specific pod, or add `all_binary!` before all targets, which makes all pods binaries.
54
55
  - pod install, and that's all
55
56
 
57
+
58
+
56
59
  **Note**: cocoapods-binary require `use_frameworks!`. If your worry about the boot time and other problems introduced by dynamic framework, static framework is a good choice. Another [plugin](https://github.com/leavez/cocoapods-static-swift-framework) made by me to make all pods static frameworks is recommended.
57
60
 
58
61
  #### Options
@@ -63,6 +66,8 @@ If your `Pods` folder is excluded from git, you may add `keep_source_code_for_pr
63
66
 
64
67
  If bitcode is needed, add a `enable_bitcode_for_prebuilt_frameworks!` before all targets in Podfile
65
68
 
69
+ if you want to all use source code, use `pod install --hsource`
70
+
66
71
 
67
72
  #### Known Issues
68
73
 
@@ -214,9 +214,12 @@ module Pod
214
214
  # https://github.com/leavez/cocoapods-binary/issues/29
215
215
  if spec.attributes_hash["resource_bundles"]
216
216
  bundle_names = spec.attributes_hash["resource_bundles"].keys
217
- spec.attributes_hash["resource_bundles"] = nil
218
- spec.attributes_hash["resources"] ||= []
219
- spec.attributes_hash["resources"] += bundle_names.map{|n| n+".bundle"}
217
+ # 只对动态库处理,静态库由mainTarget处理resource_bundles,静态库不能清空resource_bundles
218
+ if not targets.first.build_as_static_framework?
219
+ spec.attributes_hash["resource_bundles"] = nil
220
+ spec.attributes_hash["resources"] ||= []
221
+ spec.attributes_hash["resources"] += bundle_names.map{|n| n+".bundle"}
222
+ end
220
223
  end
221
224
 
222
225
  # to avoid the warning of missing license
@@ -145,8 +145,6 @@ Pod::HooksManager.register('cocoapods-binary-bel', :pre_install) do |installer_c
145
145
  lockfile = installer_context.lockfile
146
146
  binary_installer = Pod::Installer.new(prebuild_sandbox, prebuild_podfile, lockfile)
147
147
 
148
- binary_installer.delete_all_standard_sandbox_pod(standard_sandbox)
149
-
150
148
  if binary_installer.have_exact_prebuild_cache? && !update
151
149
  binary_installer.install_when_cache_hit!
152
150
  else
@@ -154,6 +152,8 @@ Pod::HooksManager.register('cocoapods-binary-bel', :pre_install) do |installer_c
154
152
  binary_installer.repo_update = repo_update
155
153
  binary_installer.install!
156
154
  end
155
+
156
+ binary_installer.delete_all_standard_sandbox_pod(standard_sandbox)
157
157
 
158
158
 
159
159
  # reset the environment
@@ -146,6 +146,14 @@ module Pod
146
146
  self.sandbox.exsited_framework_target_names.each do |name|
147
147
  UI.puts "Using #{name}" if config.verbose
148
148
  end
149
+
150
+ self.sandbox
151
+ #处理静态库resources 资源文件
152
+ self.resolve_dependencies
153
+ self.download_dependencies
154
+
155
+ self.handle_static_framework_resouces
156
+
149
157
  end
150
158
 
151
159
  def delete_standard_sand_box_pod(standard_sanbox)
@@ -173,6 +181,43 @@ module Pod
173
181
  end
174
182
  end
175
183
  end
184
+ # 处理静态库资源
185
+ def handle_static_framework_resouces
186
+ all_static_framework_targets = pod_targets.reject{|pod_target| not pod_target.static_framework? or pod_target.resource_paths.empty? }
187
+ all_static_framework_targets.each do |target|
188
+ output_path = sandbox.framework_folder_path_for_target_name(target.name)
189
+ if target.static_framework? and !target.resource_paths.empty?
190
+ framework_path = output_path + target.framework_name
191
+ standard_sandbox_path = sandbox.standard_sanbox_path
192
+ resources = begin
193
+ if Pod::VERSION.start_with? "1.5"
194
+ target.resource_paths
195
+ else
196
+ # resource_paths is Hash{String=>Array<String>} on 1.6 and above
197
+ # (use AFNetworking to generate a demo data)
198
+ # https://github.com/leavez/cocoapods-binary/issues/50
199
+ target.resource_paths.values.flatten
200
+ end
201
+ end
202
+ raise "Wrong type: #{resources}" unless resources.kind_of? Array
203
+
204
+ path_objects = resources.map do |path|
205
+ prebuild_real_path = (path.gsub('${PODS_ROOT}', sandbox.root.to_s) if path.start_with? '${PODS_ROOT}')|| ""
206
+ real_file_path = framework_path + File.basename(path)
207
+ if Pathname.new(prebuild_real_path).exist? and not Pathname.new(real_file_path).exist?
208
+ # 静态库的resource,拷贝至framework目录下
209
+ FileUtils.cp_r(prebuild_real_path, real_file_path, :remove_destination => true)
210
+ end
211
+ object = Prebuild::Passer::ResourcePath.new
212
+ object.real_file_path = real_file_path
213
+ object.target_file_path = path.gsub('${PODS_ROOT}', standard_sandbox_path.to_s) if path.start_with? '${PODS_ROOT}'
214
+ object.target_file_path = path.gsub("${PODS_CONFIGURATION_BUILD_DIR}", standard_sandbox_path.to_s) if path.start_with? "${PODS_CONFIGURATION_BUILD_DIR}"
215
+ object
216
+ end
217
+ Prebuild::Passer.resources_to_copy_for_static_framework[target.name] = path_objects
218
+ end
219
+ end
220
+ end
176
221
 
177
222
 
178
223
  # Build the needed framework files
@@ -226,7 +271,6 @@ module Pod
226
271
 
227
272
  targets = targets.reject {|pod_target| sandbox.local?(pod_target.pod_name) }
228
273
 
229
-
230
274
  # build!
231
275
  Pod::UI.puts "Prebuild frameworks (total #{targets.count})"
232
276
  Pod::Prebuild.remove_build_dir(sandbox_path)
@@ -240,37 +284,13 @@ module Pod
240
284
  output_path.rmtree if output_path.exist?
241
285
  output_path.mkpath unless output_path.exist?
242
286
  Pod::Prebuild.build(sandbox_path, target, output_path, bitcode_enabled, Podfile::DSL.custom_build_options, Podfile::DSL.custom_build_options_simulator)
243
-
244
- # save the resource paths for later installing
245
- if target.static_framework? and !target.resource_paths.empty?
246
- framework_path = output_path + target.framework_name
247
- standard_sandbox_path = sandbox.standard_sanbox_path
248
-
249
- resources = begin
250
- if Pod::VERSION.start_with? "1.5"
251
- target.resource_paths
252
- else
253
- # resource_paths is Hash{String=>Array<String>} on 1.6 and above
254
- # (use AFNetworking to generate a demo data)
255
- # https://github.com/leavez/cocoapods-binary/issues/50
256
- target.resource_paths.values.flatten
257
- end
258
- end
259
- raise "Wrong type: #{resources}" unless resources.kind_of? Array
260
-
261
- path_objects = resources.map do |path|
262
- object = Prebuild::Passer::ResourcePath.new
263
- object.real_file_path = framework_path + File.basename(path)
264
- object.target_file_path = path.gsub('${PODS_ROOT}', standard_sandbox_path.to_s) if path.start_with? '${PODS_ROOT}'
265
- object.target_file_path = path.gsub("${PODS_CONFIGURATION_BUILD_DIR}", standard_sandbox_path.to_s) if path.start_with? "${PODS_CONFIGURATION_BUILD_DIR}"
266
- object
267
- end
268
- Prebuild::Passer.resources_to_copy_for_static_framework[target.name] = path_objects
269
- end
270
-
271
- end
287
+ end
288
+ # check static_framework resources
289
+ self.handle_static_framework_resouces
272
290
  Pod::Prebuild.remove_build_dir(sandbox_path)
273
291
 
292
+
293
+
274
294
 
275
295
  # copy vendored libraries and frameworks
276
296
  targets.each do |target|
@@ -323,6 +343,7 @@ module Pod
323
343
  filename = File.basename(file)
324
344
  not to_remain_files.include?(filename)
325
345
  end
346
+
326
347
  to_delete_files.each do |path|
327
348
  path.rmtree if path.exist?
328
349
  end
@@ -2,27 +2,50 @@ module Pod
2
2
  class Command
3
3
  class Install < Command
4
4
  @@use_source = false
5
+
6
+ class << self
7
+ alias :original_options :options
8
+ end
5
9
  def self.options
6
- [
7
- ['--hsource', 'from cocoapods-binary-bel, all frameworks use source code'],
8
- ].concat(super).reject { |(name, _)| name == '--no-repo-update' }
10
+ [['--hsource', 'from cocoapods-binaryhqp, all frameworks use source code']].concat(original_options)
9
11
  end
10
12
 
13
+ alias :original_initialize :initialize
11
14
  def initialize(argv)
12
- super
13
15
  @@use_source = argv.flag?('hsource', false)
16
+ original_initialize(argv)
14
17
  end
15
18
 
16
19
  def self.all_use_source
17
20
  @@use_source
18
21
  end
19
22
 
20
- def self.run(argv)
21
- super(argv)
23
+ def self.set_all_use_source(use)
24
+ @@use_source = use
22
25
  end
23
26
 
24
27
 
25
28
  end
26
29
  end
27
30
  end
31
+
32
+ module Pod
33
+ class Command
34
+ class Update < Command
35
+ class << self
36
+ alias :original_options :options
37
+ end
38
+ def self.options
39
+ [['--hsource', 'from cocoapods-binaryhqp, all frameworks use source code']].concat(original_options)
40
+ end
41
+
42
+ alias :original_initialize :initialize
43
+ def initialize(argv)
44
+ use = argv.flag?('hsource', false)
45
+ Pod::Command::Install.set_all_use_source(use)
46
+ original_initialize(argv)
47
+ end
48
+ end
49
+ end
50
+ end
28
51
 
@@ -1,3 +1,3 @@
1
1
  module CocoapodsBinaryBel
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-binary-bel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - leavez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-05 00:00:00.000000000 Z
11
+ date: 2021-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocoapods