cocoapods-imy-bin 0.2.7 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9571b93573cfc8a24a73661aa4d8d0e27a13fdc797fef8d63cc5b5f1641f4031
4
- data.tar.gz: 428ca79deaa2875849911dd1f52ffdb32906eabcc8445d9a5cafc75f8326031f
3
+ metadata.gz: 52e4a6a4fb317bc8d4401fe5e14d842e062a26c44fe211c19fc8492d93e3ef68
4
+ data.tar.gz: e7ce061e032588ddc28ea6d9348426464eaf8a2bef89f449b92f59fe25a1bad4
5
5
  SHA512:
6
- metadata.gz: a18e4e0f9693c4718fc07910e23b24e51723f77f73ac1afe282a2ee433fade499f4b744ebd9cbd75067fea4da470d91da5c5b44044d66cda282c68a0903597bb
7
- data.tar.gz: 78b83b8d6ba156fde03afdd718a0c838deb4716d3e5474f88eba38ea351298d41d436b46e7b40e919cf2aa53298970482be2d7153f17fca8a305e262945ab4aa
6
+ metadata.gz: 5b875bfa26b32c532f4b25559c4e4320ecab97edf2263bb889dd60576a2463b566af00b9448ee38d8e8240ebab82c640159c0ef1dfb2fb043819e5f396216d0e
7
+ data.tar.gz: c8c6e6d2a46c4168b6e655326d625b0257ace4649cc2702564cca90ff4e8aa43c15f9cfeee3f40fac699eb47245a0e383a626ca18b92a0bfaeffc7138b7e3a24
data/README.md CHANGED
@@ -1,454 +1 @@
1
- # Cocoapods-imy-bin
2
1
 
3
- ## 一、概要
4
-
5
-
6
- cocoapods-imy-bin功能点:
7
-
8
- 1. 组件二进制化,`无入侵式`支持组件二进制化,完全自动化,无需手动操作。致力于解决Ci打包速度慢、研发编译慢等编译问题。
9
- 2. 本地配置文件 - `Podfile_local`
10
- 3. 二进制源码调试`pod bin code`,类似[美团 iOS 工程 zsource 命令背后的那些事儿](https://links.jianshu.com/go?to=https%3A%2F%2Ftech.meituan.com%2F2019%2F08%2F08%2Fthe-things-behind-the-ios-project-zsource-command.html)的效果。
11
- 4. 命令快捷键`pod bin imy`,如游戏快捷键,根据配置会在特定目录执行特定命令(如任意终端目录下,执行某个特定目录的pod update --no-repo-update命令),减少其他繁琐操作。支持任意个快捷键。
12
-
13
- cocoapods-imy-bin插件所关联的组件二进制化策略:
14
-
15
- 预先将打包成 `.a` 的组件保存到静态服务器上,并在 `install` 时,去下载组件对应的二进制版本,以减少组件编译时间,达到加快 App 打包、组件发布等操作的目的。
16
-
17
- 关于 插件具体的架构部署实践和更详细的资源,可以参考
18
-
19
- > [iOS编译速度如何稳定提高10倍以上](https://www.jianshu.com/p/08cffdfa2885)
20
- >
21
- > [Demo](https://github.com/su350380433/cocoapods-imy-bin-demo)
22
- >
23
-
24
-
25
- ## 二、准备工作
26
-
27
-
28
-
29
- ### 1、安装插件
30
-
31
- ```shell
32
- sudo gem install cocoapods-imy-bin
33
- ```
34
-
35
-
36
-
37
- ## 三、使用二进制组件
38
-
39
-
40
- ### 1、环境搭建
41
-
42
- <br/>
43
-
44
- [环境搭建详细教程](https://github.com/su350380433/cocoapods-imy-bin-demo)
45
-
46
- 使用二进制时,本插件需要提供以下资源:
47
-
48
- - 静态资源服务器( [binary-server](https://github.com/su350380433/binary-server),附详细使用教程)
49
- - 二进制私有源仓库(保存组件二进制版本 podspec)
50
-
51
-
52
-
53
- ### 2、初始化插件
54
-
55
- ``` shell
56
- xx:Demo slj$ pod bin init
57
-
58
- ====== dev 环境 ========
59
-
60
- 开始设置二进制化初始信息.
61
- 所有的信息都会保存在 /Users/slj/.cocoapods/bin_dev.yml 文件中.
62
- %w[bin_dev.yml bin_debug_iphoneos.yml bin_release_iphoneos.yml]
63
- 你可以在对应目录下手动添加编辑该文件. 文件包含的配置信息样式如下:
64
-
65
- ---
66
- configuration_env: dev
67
- code_repo_url: git@github.com:su350380433/example_spec_source.git
68
- binary_repo_url: git@github.com:su350380433/example_spec_bin_dev.git
69
- binary_download_url: http://localhost:8080/frameworks/%s/%s/zip
70
- download_file_type: zip
71
-
72
-
73
- 编译环境
74
- 可选值:[ dev / debug_iphoneos / release_iphoneos ]
75
- 旧值:dev
76
- ```
77
-
78
- 按提示输入`所属环境`、源码私有源、二进制私有源、二进制下载地址、下载文件类型后,插件就配置完成了。其中 `binary_download_url` 需要预留组件名称与组件版本占位符,插件内部会依次替换 `%s` 为相应组件的值。
79
-
80
- `cococapod-bin` 也支持从 url 下载配置文件,方便对多台机器进行配置:
81
-
82
- ```shell
83
- ➜ ~ pod bin init --bin-url=https://github.com/su350380433/cocoapods-imy-bin-configs/raw/master/bin_dev.yml
84
- ```
85
-
86
- 配置文件模版内容如下,根据不同团队的需求定制即可:
87
-
88
- ```shell
89
- ---
90
- configuration_env: dev
91
- code_repo_url: git@github.com:su350380433/example_spec_source.git
92
- binary_repo_url: git@github.com:su350380433/example_spec_bin_dev.git
93
- binary_download_url: http://localhost:8080/frameworks/%s/%s/zip
94
- download_file_type: zip
95
-
96
- ```
97
-
98
- 配置时,不需要手动添加源码和二进制私有源的 repo,插件在找不到对应 repo 时会主动 clone。
99
-
100
- 记得启动 `sudo mongod`服务,静态资源服务。
101
-
102
-
103
- <br/>
104
-
105
- ## 四、制作二进制组件
106
-
107
- <br/>
108
-
109
- [视频演示](https://github.com/MeetYouDevs/cocoapods-imy-bin/tree/master/%E6%BC%94%E7%A4%BA%E8%A7%86%E9%A2%91)
110
-
111
- ### 1、制作命令
112
-
113
- 可以直接使用插件的 `pod bin auto`命令,在插件初始化配置完成后,目录下只要有包含podspec文件,根据podspec文件的version版本号会自动化执行build、组装二进制组件、制作二进制podspec、上传二进制文件、上传二进制podspec到私有源仓库。
114
-
115
- ```shell
116
- pod bin auto
117
- ```
118
-
119
- 带上`—all-make`参数会把当前组件所依赖的组件都自动化制作成二进制组件。
120
-
121
- ```shell
122
- pod bin local
123
- ```
124
-
125
- pod bin local 是配合其他三方编译产物的命令,需要配置编译产物的目录。
126
-
127
- `BinArchive.json`是制作二进制的一些配置项,放在项目跟目录下:
128
-
129
- ``` json
130
- {
131
- "//": "archive-white-pod-list 不制作二进制白名单,",
132
- "archive-white-pod-list" : [
133
- "YYTargetDemo",
134
- "YYModel"
135
- ],
136
- "//": "ignore-git-list 不制作二进制 所属git白名单,",
137
- "ignore-git-list": [
138
- "git@gitlab.xxx.com:Github-iOS"
139
- ],
140
- "//": "ignore-http-list 不制作二进制 所属https白名单,",
141
- "ignore-http-list": [
142
- "https://gitlab.xxx.com/Github-iOS"
143
- ],
144
- "//": "xcode_build_path 设置编译缓存完整路径, 默认地址如下",
145
- "xcode_build_path" : "xcode-build/Build/Intermediates.noindex/ArchiveIntermediates/#{target_name}/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/",
146
- }
147
- ```
148
-
149
-
150
- <br/>
151
-
152
- ### 2. 二进制Podspec
153
-
154
- 通过`pod bin auto`和`pod bin local`二进制Podspec 会自动生成、上传,无需关心。
155
-
156
-
157
- <br/>
158
-
159
- ### 3、查看结果
160
-
161
- 二进制存储服务:http://localhost:8080/frameworks/(默认本地8080端口)
162
-
163
- 二进制私有源参考:https://github.com/su350380433/example_spec_bin_dev.git(自定义)
164
-
165
-
166
- <br/>
167
-
168
- ### 4、使用二进制
169
-
170
- <br/>
171
-
172
- [视频演示](https://github.com/MeetYouDevs/cocoapods-imy-bin/tree/master/%E6%BC%94%E7%A4%BA%E8%A7%86%E9%A2%91)
173
-
174
- 在Podfile文件中,加入这两行代码,对已经制作二进制的就会生效,自动转换二进制组件依赖。
175
-
176
- ``` ruby
177
- plugin 'cocoapods-imy-bin'
178
- use_binaries!
179
- ```
180
-
181
-
182
- <br/>
183
-
184
- ## 五、扩展功能
185
-
186
- <br/>
187
-
188
- ### 1、本地配置文件 - Podfile_local
189
-
190
- 本地组件配置文件 Podfile_local,目前已支持Podfile下的大部分功能,可以把一些本地配置的语句放到Podfile_local。
191
-
192
- <img src="https://raw.githubusercontent.com/MeetYouDevs/cocoapods-imy-bin/master/img/Podfile_local.png" style="zoom:50%;" />
193
-
194
- 场景:
195
-
196
- 1. 不希望把本地采用的源码/二进制配置、本地库传到远程仓库。
197
- 2. 避免直接修改Podfile文件,引起更新代码时冲突、或者误提交。
198
-
199
- 如Podfile本地库的写法:
200
- ```ruby
201
- pod YYModel :path => '../' #提交的时候往往要修改回来才提交,操作繁琐
202
- ```
203
- 用法:
204
-
205
- 在与Podfile同级目录下,新增一个`Podfile_local`文件,模板可到这里下载Podfile_local
206
-
207
-
208
- ```ruby
209
- #target 'Seeyou' do 不同的项目注意修改下Seeyou的值
210
- #:path => '../IMYYQHome',根据实际情况自行修改,与之前在podfile写法一致
211
-
212
-
213
- plugin 'cocoapods-imy-bin'
214
- #是否启用二进制插件,想开启把下面注释去掉
215
- # use_binaries!
216
-
217
- #设置使用【源码】版本的组件。
218
- #set_use_source_pods ['YYKit','SDWebImaage']
219
-
220
- #需要替换Podfile里面的组件才写到这里
221
- #在这里面的所写的组件库依赖,默认切换为【源码】依赖
222
- target 'Seeyou' do
223
- #本地库引用
224
- #pod 'YYModel', :path => '../YYModel'
225
-
226
- #覆盖、自定义组件
227
- #pod 'YYCache', :podspec => 'http://覆盖、自定义/'
228
- end
229
- ```
230
-
231
- ```ruby
232
- 以前的 pod update --no-repo-update 命令加个前缀 `bin` 变成
233
- ```
234
-
235
- ```shell
236
- pod bin update --no-repo-update
237
- ```
238
- or
239
- ```shell
240
- pod bin install
241
- ```
242
-
243
- 支持 pod install/update 命令参数
244
-
245
- 并将其加入 .gitignore ,再也不用担心我误提交或者冲突了,Podfile_local 中的配置选项优先级比 Podfile 高,支持和 Podfile 相同的配置语句,同时支持**pre_install** or **post_install**。
246
-
247
-
248
- 如果您不习惯Podfile_local的使用方式,可以把命令写在Podfile里面,pod时不需要加bin,依旧是 pod update/install。
249
-
250
-
251
- <br/>
252
-
253
- ### 2、二进制源码调试
254
-
255
- <br/>
256
-
257
- [视频演示](https://github.com/MeetYouDevs/cocoapods-imy-bin/tree/master/%E6%BC%94%E7%A4%BA%E8%A7%86%E9%A2%91)
258
-
259
- 在项目根目录下,输入命令:
260
-
261
- ```ruby
262
- pod bin code YYModel
263
- ```
264
-
265
- `YYModel`为需要源码调试的组件库名称。成功之后像平时一样单步调试,控制台打印变量。让我们同时拥有使用二进制的便利和源码调试的能力。
266
-
267
- ``` shell
268
- $ pod bin code --help [11:37:50]
269
- Usage:
270
-
271
- $ pod bin code [NAME]
272
-
273
- 通过将二进制对应源码放置在临时目录中,让二进制出现断点时可以跳到对应的源码,方便调试。 在不删除二进制的情况下为某个组件添加源码调试能力,多个组件名称用空格分隔
274
-
275
- Options:
276
-
277
- --all-clean 删除所有已经下载的源码
278
- --clean 删除所有指定下载的源码
279
- --list 展示所有一级下载的源码以及其大小
280
- --source 源码路径,本地路径,会去自动链接本地源码
281
- ```
282
-
283
- 效果与演示参考[链接1](https://juejin.im/post/5eccceb9f265da76f30e4e13#heading-48)、[视频](https://github.com/MeetYouDevs/cocoapods-imy-bin/tree/master/%E6%BC%94%E7%A4%BA%E8%A7%86%E9%A2%91)
284
-
285
-
286
- <br/>
287
-
288
- ### 3、快捷键命令
289
-
290
- <br/>
291
-
292
- 在任意的终端执行命令,都能执行特定目录下特定命令
293
-
294
- 使用命令:
295
-
296
- ```shell
297
- pod bin imy
298
- ```
299
-
300
- or
301
-
302
- ``` shell
303
- pod bin imy 2 #2 是自定义的快捷键
304
- ```
305
-
306
- 使用场景:
307
-
308
- 1. 在任意目录下,执行项目A的pod update --no-repo-update命令
309
-
310
- 命令快捷键配置
311
-
312
- ```shell
313
- $ pod bin inithk [11:37:58]
314
-
315
- 开始设置快捷键 pod bin imy.
316
- 所有的信息都会保存在 /Users/ci/.cocoapods/hot_key_1.yml 文件中.
317
- %w[hot_key.yaml]
318
- 你可以在对应目录下手动添加编辑该文件. 文件包含的配置信息样式如下:
319
-
320
- ---
321
- hot_key_index: '1'
322
- hot_key_dir: '/User/ci/自定义目录'
323
- hot_key_cmd: pod bin update --no-repo-update
324
-
325
-
326
- 快捷键
327
- 可选值:[ 1 / 2 / 3... ]
328
- 旧值:1
329
- ```
330
-
331
-
332
- <br/>
333
-
334
- ## 六、 DSL参数解释
335
-
336
-
337
-
338
- 首先,开发者需要在 Podfile 中需要使用 `plugin 'cocoapods-imy-bin'` 语句引入插件
339
-
340
- ```ruby
341
- plugin 'cocoapods-imy-bin'
342
- ```
343
-
344
- 顺带可以删除 Podfile 中的 source ,因为插件内部会自动帮你添加两个私有源。
345
-
346
- `cocoapods-bin `插件提供二进制相关的配置语句有 `use_binaries!`、`use_binaries_with_spec_selector!` 以及 `set_use_source_pods`,下面会分别介绍。
347
-
348
- ##### use_binaries!
349
-
350
- 全部组件使用二进制版本。
351
-
352
- 支持传入布尔值控制是否使用二进制版本,比如 DEBUG 包使用二进制版本,正式包使用源码版本,Podfile 关联语句可以这样写:
353
-
354
- ```ruby
355
- use_binaries! (ENV['DEBUG'].nil? || ENV['DEBUG'] == 'true')
356
- ```
357
-
358
- ##### set_use_source_pods
359
-
360
- 设置使用源码版本的组件。
361
-
362
- 实际开发中,可能需要查看 YYModel 组件的源码,这时候可以这么设置:
363
-
364
- ```ruby
365
- set_use_source_pods ['YYModel']
366
- ```
367
-
368
- 如果 CocoaPods 版本为 1.5.3 ,终端会输出以下内容,表示 YYModel 的参照源从二进制私有源切换到了源码私有源:
369
-
370
- ```ruby
371
- Analyzing dependencies
372
- Fetching podspec for `A` from `../`
373
- Downloading dependencies
374
- Using A (0.1.0)
375
- Installing YYModel 1.0.4.2 (source changed to `git@git.xxxxxx.net:ios/cocoapods-spec.git` from `git@git.xxxxxx.net:ios/cocoapods-spec-binary.git`)
376
- Generating Pods project
377
- Integrating client project
378
- Sending stats
379
- Pod installation complete! There is 1 dependency from the Podfile and 2 total pods installed.
380
- ```
381
-
382
- ##### use_binaries_with_spec_selector!
383
-
384
- 过滤出需要使用二进制版本组件。
385
-
386
- 假如开发者只需要 `YYModel` 的二进制版本,那么他可以在 Podfile 中添加以下代码:
387
-
388
- ```ruby
389
- use_binaries_with_spec_selector! do |spec|
390
- spec.name == 'YYModel'
391
- end
392
- ```
393
-
394
- **需要注意的是,如果组件有 subspec ,使用组件名作为判断条件应如下**:
395
-
396
- ```ruby
397
- use_binaries_with_spec_selector! do |spec|
398
- spec.name.start_with? == '组件名'
399
- end
400
- ```
401
-
402
- 如果像上个代码块一样,**直接对比组件名,则插件会忽略此组件的所有 subspec,导致资源拉取错误**,这种场景下,最好通过 `set_use_source_pods` 语句配置依赖。
403
-
404
- 一个实际应用是,三方组件采用二进制版本,团队编写的组件依旧采用源码版本。如果三方组件都在 `cocoapods-repo` 组下,就可以使用以下代码过滤出三方组件:
405
-
406
- ```ruby
407
- use_binaries_with_spec_selector! do |spec|
408
- git = spec.source && spec.source['git']
409
- git && git.include?('cocoapods-repo')
410
- end
411
- ```
412
-
413
- ##### 切换Dev/Debug_iPhoneos/Release_iPhoneos环境初始化设置
414
-
415
-
416
- ```shell
417
- #dev 初始化插件配置 默认dev环境
418
- pod bin init --bin-url=https://gitlab.xxx.com/cocoapods-imy-bin-config/raw/master/bin_dev.yml
419
-
420
- #Debug_iPhoneos 初始化插件配置
421
- pod bin init --bin-url=https://gitlab.xxx.com/cocoapods-imy-bin-config/raw/master/bin_debug_iphoneos.yml
422
-
423
-
424
- #release_iPhoneos 初始化插件配置
425
- pod bin init --bin-url=https://gitlab.xxx.com/cocoapods-imy-bin-config/raw/master/bin_release_iphoneos.yml
426
- ```
427
-
428
- 使用时在podfile 或者 podfile_local指定设置
429
-
430
- ```shell
431
- #在podfile 或者 podfile_local 文件下加这句话
432
- set_configuration_env('debug_iphoneos')
433
- ```
434
-
435
- ##### 其他设置
436
-
437
- 插件默认开启多线程下载组件资源,如果要禁用这个功能,Podfile 添加以下代码即可:
438
-
439
- ```ruby
440
- install! 'cocoapods', { install_with_multi_threads: false }
441
- ```
442
-
443
-
444
- <br/>
445
-
446
- ## 七、感谢
447
-
448
-
449
-
450
- **[cocoapods-bin](https://github.com/tripleCC/cocoapods-bin)**
451
-
452
- [美团 iOS 工程 zsource 命令背后的那些事儿](https://links.jianshu.com/go?to=https%3A%2F%2Ftech.meituan.com%2F2019%2F08%2F08%2Fthe-things-behind-the-ios-project-zsource-command.html)
453
-
454
- #### 您有什么更好的想法,可以提出来,我们一起来实现,共创一个强大的平台,同时也欢迎给我们提PR。
@@ -127,7 +127,8 @@ module Pod
127
127
  false ,
128
128
  @config)
129
129
  builder.build
130
- rescue
130
+ rescue Object => exception
131
+ UI.puts exception
131
132
  fail_build_specs << spec
132
133
  end
133
134
  end
@@ -1,6 +1,6 @@
1
1
 
2
2
  module CBin
3
- VERSION = '0.2.7'
3
+ VERSION = '0.2.8'
4
4
  end
5
5
 
6
6
  module Pod
@@ -221,7 +221,12 @@ module CBin
221
221
 
222
222
  #by slj 如果没有头文件,去 "Headers/Public"拿
223
223
  # if public_headers.empty?
224
- Dir.chdir("./Headers/Public/#{@spec.name}") do
224
+ spec_header_dir = "./Headers/Public/#{@spec.name}"
225
+ unless File.exist?(spec_header_dir)
226
+ spec_header_dir = "./Pods/Headers/Public/#{@spec.name}"
227
+ end
228
+ raise "copy_headers #{spec_header_dir} no exist " unless File.exist?(spec_header_dir)
229
+ Dir.chdir(spec_header_dir) do
225
230
  headers = Dir.glob('*.h')
226
231
  headers.each do |h|
227
232
  public_headers << Pathname.new(File.join(Dir.pwd,h))
@@ -270,8 +275,11 @@ module CBin
270
275
  end
271
276
 
272
277
  def copy_resources
278
+ resource_dir = './build/*.bundle'
279
+ resource_dir = './build-armv7/*.bundle' if File.exist?('./build-armv7')
280
+ resource_dir = './build-arm64/*.bundle' if File.exist?('./build-arm64')
273
281
 
274
- bundles = Dir.glob('./build/*.bundle')
282
+ bundles = Dir.glob(resource_dir)
275
283
 
276
284
  bundle_names = [@spec, *@spec.recursive_subspecs].flat_map do |spec|
277
285
  consumer = spec.consumer(@platform)
@@ -292,7 +300,13 @@ module CBin
292
300
  `cp -rp #{bundle_files} #{framework.resources_path} 2>&1`
293
301
  end
294
302
 
295
- real_source_dir = @isRootSpec ? @source_dir : Pathname.new(File.join(Dir.pwd,"#{@spec.name}"))
303
+ spec_source_dir = File.join(Dir.pwd,"#{@spec.name}")
304
+ unless File.exist?(spec_source_dir)
305
+ spec_source_dir = File.join(Dir.pwd,"Pods/#{@spec.name}")
306
+ end
307
+ raise "copy_resources #{spec_source_dir} no exist " unless File.exist?(spec_source_dir)
308
+
309
+ real_source_dir = @isRootSpec ? @source_dir : spec_source_dir
296
310
  resources = [@spec, *@spec.recursive_subspecs].flat_map do |spec|
297
311
  expand_paths(real_source_dir, spec.consumer(@platform).resources)
298
312
  end.compact.uniq
@@ -38,12 +38,12 @@ module CBin
38
38
 
39
39
  def make_headers
40
40
  @headers_path = @versions_path + Pathname.new('Headers')
41
- # @headers_path.mkpath unless @headers_path.exist?
41
+ @headers_path.mkpath unless @headers_path.exist?
42
42
  end
43
43
 
44
44
  def make_resources
45
45
  @resources_path = @versions_path + Pathname.new('Resources')
46
- # @resources_path.mkpath unless @resources_path.exist?
46
+ @resources_path.mkpath unless @resources_path.exist?
47
47
  end
48
48
 
49
49
  def make_root
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-imy-bin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - 苏良锦
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-06 00:00:00.000000000 Z
11
+ date: 2020-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parallel