cocoapods-bin 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +419 -10
- data/lib/cocoapods-bin/command/bin/repo/push.rb +2 -2
- data/lib/cocoapods-bin/gem_version.rb +1 -1
- data/lib/cocoapods-bin/native/installer.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f342602d96ee53fc2007e37834b6d85dd525d1c5
|
4
|
+
data.tar.gz: 9cfb51a1b306bbe877a6e52e889e92fa18b532c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01bd2ad57ad43af67be44582edca253362797869d5c3ebbd4e5571e9aca1a78bb450f2c892dc8fbab03169897bd5f337406aa18e9dbbd15ad50727a46ff092c6
|
7
|
+
data.tar.gz: de8a6e0ae25a8dfe2f55c491100294c23981cc14b323d1b2324eccfd00e25c21d964538824c6a6fce67c46a71627ea73fa48c469ed2cfbb1d10da9469f296f1d
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -2,23 +2,432 @@
|
|
2
2
|
|
3
3
|
组件二进制化插件。
|
4
4
|
|
5
|
-
|
5
|
+
## 概要
|
6
6
|
|
7
|
-
|
7
|
+
本插件所关联的组件二进制化策略:
|
8
8
|
|
9
|
-
|
10
|
-
2. 更快的首次下载速度。源码依赖只进行 clone 源码操作,二进制依赖只进行 http 下载二进制操作。在大部分组件都是二进制依赖时,较少的 clone 操作可以减少 install 耗时。并且 cocoapods-bin 提供了多线程下载组件的功能,可以极大地提升 install 时 `Downloading dependencies` 的执行速度。
|
11
|
-
3. 更好的扩展性。拆封成两个 podspec 之后,有利于在二进制 podspec 中处理一些拥有较复杂 subspec 的组件。
|
9
|
+
预先将打包成 `.a` 或者 `.framework` 的组件(接入此插件必须使用 `.framework`)保存到静态服务器上,并在 `install` 时,去下载组件对应的二进制版本,以减少组件编译时间,达到加快 App 打包、组件 lint、组件发布等操作的目的。
|
12
10
|
|
11
|
+
使用本插件需要提供以下资源:
|
13
12
|
|
14
|
-
|
13
|
+
- 静态资源服务器(可参考 [binary-server](https://github.com/tripleCC/binary-server.git))
|
14
|
+
- 源码私有源(保存组件源码版本 podspec)
|
15
|
+
- 二进制私有源(保存组件二进制版本 podspec)
|
15
16
|
|
16
|
-
|
17
|
+
在所有组件都依赖二进制版本的情况下,本插件支持切换指定组件的依赖版本。
|
17
18
|
|
18
|
-
|
19
|
+
推荐结合 GitLab CI 使用本插件,可以实现自动打包发布,并显著减少其 pipeline 耗时。关于 GitLab CI 的实践,可以参考 [火掌柜 iOS 团队 GitLab CI 集成实践](https://triplecc.github.io/2018/06/23/2018-06-23-ji-gitlabcide-ci-shi-jian/)。虽然后来对部分 stage 和脚本都进行了优化,但总体构建思路还是没变的。
|
20
|
+
|
21
|
+
## 准备工作
|
22
|
+
|
23
|
+
安装 `cocoapods-bin`:
|
19
24
|
|
20
25
|
$ gem install cocoapods-bin
|
21
26
|
|
22
|
-
|
27
|
+
初始化插件:
|
28
|
+
|
29
|
+
```shell
|
30
|
+
➜ ~ pod bin init
|
31
|
+
|
32
|
+
开始设置二进制化初始信息.
|
33
|
+
所有的信息都会保存在 /Users/songruiwang/.cocoapods/bin.yml 文件中.
|
34
|
+
你可以在对应目录下手动添加编辑该文件. 文件包含的配置信息如下:
|
35
|
+
|
36
|
+
---
|
37
|
+
code_repo_url: 源码私有源 Git 地址,如> git@git.2dfire.net:ios/cocoapods-spec.git
|
38
|
+
binary_repo_url: 二进制私有源 Git 地址,如> git@git.2dfire.net:ios/cocoapods-spec-binary.git
|
39
|
+
binary_download_url: 二进制下载地址,内部会依次传入组件名称与版本,替换字符串中的 %s ,如> http://iosframeworkserver-shopkeeperclient.app.2dfire.com/download/%s/%s.zip
|
40
|
+
|
41
|
+
|
42
|
+
源码私有源 Git 地址,如> git@git.2dfire.net:ios/cocoapods-spec.git
|
43
|
+
旧值:git@git.2dfire.net:ios/cocoapods-spec.git
|
44
|
+
>
|
45
|
+
|
46
|
+
```
|
47
|
+
|
48
|
+
按提示输入源码私有源、二进制私有源、二进制下载地址后,插件就配置完成了。
|
49
|
+
|
50
|
+
`cococapod-bin` 也支持从 url 下载配置文件,方便对多台机器进行配置:
|
51
|
+
|
52
|
+
```shell
|
53
|
+
➜ ~ pod bin init --bin-url=http://git.2dfire.net/qingmu/cocoapods-tdfire-binary-config/raw/master/bin.yml
|
54
|
+
```
|
55
|
+
|
56
|
+
配置文件模版内容如下,根据不同团队的需求定制即可:
|
57
|
+
|
58
|
+
```yaml
|
59
|
+
---
|
60
|
+
code_repo_url: git@git.2dfire.net:ios/cocoapods-spec.git
|
61
|
+
binary_repo_url: git@git.2dfire.net:ios/cocoapods-spec-binary.git
|
62
|
+
binary_download_url: http://iosframeworkserver-shopkeeperclient.app.2dfire.com/download/%s/%s.zip
|
63
|
+
```
|
64
|
+
|
65
|
+
配置时,不需要手动添加源码和二进制私有源的 repo,插件在找不到对应 repo 时会主动 clone。
|
66
|
+
|
67
|
+
插件配置完后,就可以部署静态资源服务器了。对于静态资源服务器,这里不做赘述,只提示一点:**`binary_download_url` 需要以资源类型结尾(例子为 zip 类型)**。
|
68
|
+
|
69
|
+
插件为了保证资源类型的多样性,在生成二进制 podspec 时并没有定死 source 的 `:type` 字段,所以 CocoaPods 只能从 url 中获取资源类型。在下载 http/https 资源时,CocoaPods 会根据路径的 extname 检查资源类型,不符合要求的话(zip、tgz、tar、tbz、txz、dmg)就会直接抛错。这里提到了 **二进制 podspec 的自动生成**,后面会详细介绍。
|
70
|
+
|
71
|
+
这里额外说下打包工具 [cocoapods-packager](https://github.com/CocoaPods/cocoapods-packager) 和 [Carthage](https://github.com/Carthage/Carthage/issues) ,前者可以通过 podspec 进行打包,只要保证 lint 通过了,就可以打成 `.framework`,很方便,但是作者几乎不维护了,后者需要结合组件工程。具体使用哪个可以结合自身团队,甚至可以自己写打包脚本。
|
72
|
+
|
73
|
+
## 使用插件
|
74
|
+
|
75
|
+
### 基本信息
|
76
|
+
|
77
|
+
`cocoapods-bin` 命令行信息可以输入以下命令查看:
|
78
|
+
|
79
|
+
```shell
|
80
|
+
➜ ~ pod bin --help
|
81
|
+
Usage:
|
82
|
+
|
83
|
+
$ pod bin [COMMAND]
|
84
|
+
|
85
|
+
组件二进制化插件。利用源码私有源与二进制私有源实现对组件依赖类型的切换。
|
86
|
+
|
87
|
+
Commands:
|
88
|
+
|
89
|
+
+ init 初始化插件.
|
90
|
+
+ lib 管理二进制 pod.
|
91
|
+
+ list 展示二进制 pods .
|
92
|
+
> open 打开 workspace 工程.
|
93
|
+
+ repo 管理 spec 仓库.
|
94
|
+
+ search 查找二进制 spec.
|
95
|
+
+ spec 管理二进制 spec.
|
96
|
+
```
|
97
|
+
|
98
|
+
### 二进制 podspec
|
99
|
+
|
100
|
+
`cocoapods-bin` 针对一个组件,同时使用了两种 podspec,分别为源码 podspec 和二进制 podspec,这种方式在没有工具支撑的情况下,势必会增加开发者维护组件的工作量。做为开发者来说,我是不希望同时维护两套 podspec 的。为了解决这个问题, 插件提供了自动生成二进制 podspec 功能,开发者依旧只需要关心源码 podspec 即可。
|
101
|
+
|
102
|
+
一般来说,在接入插件前,组件源码 podspec 是已经存在的,所以我们只需要向二进制私有源推送组件的二进制 podspec 即可。如果有条件的话,二进制和源码 podspec 的发布可以走 GitLab CI ,这也是我推荐的做法。
|
103
|
+
|
104
|
+
下面介绍下和二进制 podspec 相关的 `cocoapods-bin` 命令。
|
105
|
+
|
106
|
+
#### pod bin spec create
|
107
|
+
|
108
|
+
```shell
|
109
|
+
➜ ~ pod bin spec create --help
|
110
|
+
Usage:
|
111
|
+
|
112
|
+
$ pod bin spec create
|
113
|
+
|
114
|
+
根据源码 podspec 文件,创建对应的二进制 podspec 文件.
|
115
|
+
|
116
|
+
Options:
|
117
|
+
|
118
|
+
--platforms=ios 生成二进制 spec 支持的平台
|
119
|
+
--template-podspec=A.binary-template.podspec 生成拥有 subspec 的二进制 spec 需要的模版
|
120
|
+
podspec, 插件会更改 version 和 source
|
121
|
+
--no-overwrite 不允许覆盖
|
122
|
+
...
|
123
|
+
```
|
124
|
+
|
125
|
+
`pod bin spec create` 会根据源码 podspec ,创建出二进制 podspec 文件。如果组件存在 subspec ,需要开发者提供 podspec 模版信息,以生成二进制 podspec。插件会根据源码 podspec 更改模版中的 version 字段,并且根据插件配置的 `binary_download_url` 生成 source 字段,最终生成二进制 podspec。
|
126
|
+
|
127
|
+
以 A 组件举例,如果 A 的 podspec 如下:
|
128
|
+
|
129
|
+
```ruby
|
130
|
+
Pod::Spec.new do |s|
|
131
|
+
s.name = 'A'
|
132
|
+
s.version = '0.1.0'
|
133
|
+
s.summary = 'business A short description of A.'
|
134
|
+
s.description = <<-DESC
|
135
|
+
TODO: Add long description of the pod here.
|
136
|
+
DESC
|
137
|
+
s.homepage = 'http://git.2dfire-inc.com/ios/A'
|
138
|
+
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
139
|
+
s.author = { 'qingmu' => 'qingmu@2dfire.com' }
|
140
|
+
s.source = { :git => 'http://git.2dfire-inc.com/qiandaojiang/A.git', :tag => s.version.to_s }
|
141
|
+
s.ios.deployment_target = '8.0'
|
142
|
+
s.source_files = 'A/Classes/**/*'
|
143
|
+
s.public_header_files = 'A/Classes/**/*.{h}'
|
144
|
+
s.resource_bundles = {
|
145
|
+
'A' => ['A/Assets/*']
|
146
|
+
}
|
147
|
+
end
|
148
|
+
```
|
149
|
+
|
150
|
+
那么生成的 `A.binary.podspec.json` 如下:
|
151
|
+
|
152
|
+
```json
|
153
|
+
{
|
154
|
+
"name": "A",
|
155
|
+
"version": "0.1.0",
|
156
|
+
"summary": "business A short description of A.",
|
157
|
+
"description": "TODO: Add long description of the pod here.",
|
158
|
+
"homepage": "http://git.2dfire-inc.com/ios/A",
|
159
|
+
"license": {
|
160
|
+
"type": "MIT",
|
161
|
+
"file": "LICENSE"
|
162
|
+
},
|
163
|
+
"authors": {
|
164
|
+
"qingmu": "qingmu@2dfire.com"
|
165
|
+
},
|
166
|
+
"source": {
|
167
|
+
"http": "http://iosframeworkserver-shopkeeperclient.app.2dfire.com/download/A/0.1.0.zip"
|
168
|
+
},
|
169
|
+
"platforms": {
|
170
|
+
"ios": "8.0"
|
171
|
+
},
|
172
|
+
"source_files": [
|
173
|
+
"A.framework/Headers/*",
|
174
|
+
"A.framework/Versions/A/Headers/*"
|
175
|
+
],
|
176
|
+
"public_header_files": [
|
177
|
+
"A.framework/Headers/*",
|
178
|
+
"A.framework/Versions/A/Headers/*"
|
179
|
+
],
|
180
|
+
"vendored_frameworks": "A.framework",
|
181
|
+
"resources": [
|
182
|
+
"A.framework/Resources/*.bundle",
|
183
|
+
"A.framework/Versions/A/Resources/*.bundle"
|
184
|
+
]
|
185
|
+
}
|
186
|
+
```
|
187
|
+
|
188
|
+
如果 A 拥有 subspec:
|
189
|
+
|
190
|
+
```ruby
|
191
|
+
Pod::Spec.new do |s|
|
192
|
+
s.name = 'A'
|
193
|
+
s.version = '0.1.0'
|
194
|
+
s.summary = 'business A short description of A.'
|
195
|
+
s.description = <<-DESC
|
196
|
+
TODO: Add long description of the pod here.
|
197
|
+
DESC
|
198
|
+
s.homepage = 'http://git.2dfire-inc.com/ios/A'
|
199
|
+
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
200
|
+
s.author = { 'qingmu' => 'qingmu@2dfire.com' }
|
201
|
+
s.source = { :git => 'http://git.2dfire-inc.com/qiandaojiang/A.git', :tag => s.version.to_s }
|
202
|
+
s.ios.deployment_target = '8.0'
|
203
|
+
s.source_files = 'A/Classes/**/*'
|
204
|
+
s.public_header_files = 'A/Classes/**/*.{h}'
|
205
|
+
s.resource_bundles = {
|
206
|
+
'A' => ['A/Assets/*']
|
207
|
+
}
|
208
|
+
s.subspec 'B' do |ss|
|
209
|
+
ss.dependency 'YYModel'
|
210
|
+
ss.source_files = 'A/Classes/**/*'
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
```
|
215
|
+
|
216
|
+
那么就需要开发者提供 `A.binary-templte.podspec`(此模版中的写法假定组件的所有 subspec 都打进一个 `.framework` 里,如果 subpsec 都有属于自己的 `.framework` ,就可以采用其他写法。) :
|
217
|
+
|
218
|
+
```ruby
|
219
|
+
Pod::Spec.new do |s|
|
220
|
+
s.name = 'A'
|
221
|
+
s.summary = 'business A short description of A.'
|
222
|
+
s.description = <<-DESC
|
223
|
+
TODO: Add long description of the pod here.
|
224
|
+
DESC
|
225
|
+
s.homepage = 'http://git.2dfire-inc.com/ios/A'
|
226
|
+
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
227
|
+
s.author = { 'qingmu' => 'qingmu@2dfire.com' }
|
228
|
+
s.ios.deployment_target = '8.0'
|
229
|
+
s.subspec "Binary" do |ss|
|
230
|
+
ss.vendored_frameworks = "#{s.name}.framework"
|
231
|
+
ss.source_files = "#{s.name}.framework/Headers/*", "#{s.name}.framework/Versions/A/Headers/*"
|
232
|
+
ss.public_header_files = "#{s.name}.framework/Headers/*", "#{s.name}.framework/Versions/A/Headers/*"
|
233
|
+
ss.dependency 'YYModel'
|
234
|
+
end
|
235
|
+
s.subspec 'B' do |ss|
|
236
|
+
ss.dependency "#{s.name}/Binary"
|
237
|
+
end
|
238
|
+
end
|
239
|
+
```
|
240
|
+
|
241
|
+
最终生成的二进制 podspec 如下:
|
242
|
+
|
243
|
+
```json
|
244
|
+
{
|
245
|
+
"name": "A",
|
246
|
+
"summary": "business A short description of A.",
|
247
|
+
"description": "TODO: Add long description of the pod here.",
|
248
|
+
"homepage": "http://git.2dfire-inc.com/ios/A",
|
249
|
+
"license": {
|
250
|
+
"type": "MIT",
|
251
|
+
"file": "LICENSE"
|
252
|
+
},
|
253
|
+
"authors": {
|
254
|
+
"qingmu": "qingmu@2dfire.com"
|
255
|
+
},
|
256
|
+
"platforms": {
|
257
|
+
"ios": "8.0"
|
258
|
+
},
|
259
|
+
"version": "0.1.0",
|
260
|
+
"source": {
|
261
|
+
"http": "http://iosframeworkserver-shopkeeperclient.app.2dfire.com/download/A/0.1.0.zip"
|
262
|
+
},
|
263
|
+
"subspecs": [
|
264
|
+
{
|
265
|
+
"name": "Binary",
|
266
|
+
"vendored_frameworks": "A.framework",
|
267
|
+
"source_files": [
|
268
|
+
"A.framework/Headers/*",
|
269
|
+
"A.framework/Versions/A/Headers/*"
|
270
|
+
],
|
271
|
+
"public_header_files": [
|
272
|
+
"A.framework/Headers/*",
|
273
|
+
"A.framework/Versions/A/Headers/*"
|
274
|
+
]
|
275
|
+
},
|
276
|
+
{
|
277
|
+
"name": "B",
|
278
|
+
"dependencies": {
|
279
|
+
"A/Binary": [
|
280
|
+
|
281
|
+
]
|
282
|
+
}
|
283
|
+
}
|
284
|
+
]
|
285
|
+
}
|
286
|
+
```
|
287
|
+
|
288
|
+
#### pod bin spec lint
|
289
|
+
|
290
|
+
```shell
|
291
|
+
➜ ~ pod bin spec lint --help
|
292
|
+
Usage:
|
293
|
+
|
294
|
+
$ pod bin spec lint [NAME.podspec|DIRECTORY|http://PATH/NAME.podspec ...]
|
295
|
+
|
296
|
+
spec lint 二进制组件 / 源码组件
|
297
|
+
|
298
|
+
Options:
|
299
|
+
|
300
|
+
--binary lint 组件的二进制版本
|
301
|
+
--template-podspec=A.binary-template.podspec 生成拥有 subspec 的二进制 spec 需要的模版
|
302
|
+
podspec, 插件会更改 version 和 source
|
303
|
+
--reserve-created-spec 保留生成的二进制 spec 文件
|
304
|
+
--code-dependencies 使用源码依赖进行 lint
|
305
|
+
--loose-options 添加宽松的 options, 包括 --use-libraries
|
306
|
+
(可能会造成 entry point (start)
|
307
|
+
undefined)
|
308
|
+
...
|
309
|
+
```
|
310
|
+
|
311
|
+
`pod bin spec lint` 默认使用二进制依赖进行 lint,在添加 `--binary` 会去 lint 当前组件的二进制 podspec(动态生成)。在添加 `--code-dependencies` 将会使用源码依赖进行 lint ,个人推荐使用二进制依赖 lint,可以极大地减少编译时间。
|
312
|
+
|
313
|
+
#### pod bin repo push
|
314
|
+
|
315
|
+
```shell
|
316
|
+
|
317
|
+
➜ ~ pod bin repo push --help
|
318
|
+
Usage:
|
319
|
+
|
320
|
+
$ pod bin repo push [NAME.podspec]
|
321
|
+
|
322
|
+
发布二进制组件 / 源码组件
|
323
|
+
|
324
|
+
Options:
|
325
|
+
|
326
|
+
--binary 发布组件的二进制版本
|
327
|
+
--template-podspec=A.binary-template.podspec 生成拥有 subspec 的二进制 spec 需要的模版
|
328
|
+
podspec, 插件会更改 version 和 source
|
329
|
+
--reserve-created-spec 保留生成的二进制 spec 文件
|
330
|
+
--code-dependencies 使用源码依赖进行 lint
|
331
|
+
--loose-options 添加宽松的 options, 包括
|
332
|
+
--use-libraries (可能会造成 entry
|
333
|
+
point (start) undefined)
|
334
|
+
...
|
335
|
+
```
|
336
|
+
|
337
|
+
`pod bin repo push` 用来发布组件,其余特性和 `pod bin spec lint` 一致。
|
338
|
+
|
339
|
+
### Podfile DSL
|
340
|
+
|
341
|
+
首先,开发者需要在 Podfile 中需要使用 `plugin 'cocoapods-bin'` 语句引入插件 :
|
342
|
+
|
343
|
+
```ruby
|
344
|
+
plugin 'cocoapods-bin'
|
345
|
+
```
|
346
|
+
|
347
|
+
顺带可以删除 Podfile 中的 source ,因为插件内部会自动帮你添加两个私有源。
|
348
|
+
|
349
|
+
`cocoapods-bin `插件提供二进制相关的配置语句有 `use_binaries!`、`use_binaries_with_spec_selector!` 以及 `set_use_source_pods`,下面会分别介绍。
|
350
|
+
|
351
|
+
#### use_binaries!
|
352
|
+
|
353
|
+
全部组件使用二进制版本。
|
354
|
+
|
355
|
+
当组件没有二进制版本时,插件会强制工程依赖该组件的源码版本。开发者可以通过执行 `pod install--verbose` option ,在分析依赖步骤查看哪些组件没有二进制版本:
|
356
|
+
|
357
|
+
```shell
|
358
|
+
...
|
359
|
+
Resolving dependencies of `Podfile`
|
360
|
+
【AMapFrameworks | 0.0.4】组件无对应二进制版本 , 将采用源码依赖.
|
361
|
+
【ActivityForRestApp | 0.2.1】组件无对应二进制版本 , 将采用源码依赖.
|
362
|
+
【AssemblyComponent | 0.5.9】组件无对应二进制版本 , 将采用源码依赖.
|
363
|
+
【Bugly | 2.4.6】组件无对应二进制版本 , 将采用源码依赖.
|
364
|
+
【Celebi | 0.6.4】组件无对应二进制版本 , 将采用源码依赖.
|
365
|
+
【CocoaAsyncSocket/RunLoop | 7.4.3】组件无对应二进制版本 , 将采用源码依赖.
|
366
|
+
【CocoaLumberjack | 3.4.1】组件无对应二进制版本 , 将采用源码依赖.
|
367
|
+
【CocoaLumberjack/Default | 3.4.1】组件无对应二进制版本 , 将采用源码依赖.
|
368
|
+
【CocoaLumberjack/Extensions | 3.4.1】组件无对应二进制版本 , 将采用源码依赖.
|
369
|
+
【CodePush | 0.3.1】组件无对应二进制版本 , 将采用源码依赖.
|
370
|
+
【CodePush/Core | 0.3.1】组件无对应二进制版本 , 将采用源码依赖.
|
371
|
+
【CodePush/SSZipArchive | 0.3.1】组件无对应二进制版本 , 将采用源码依赖.
|
372
|
+
【ESExchangeSkin | 0.3.2】组件无对应二进制版本 , 将采用源码依赖.
|
373
|
+
...
|
374
|
+
```
|
375
|
+
|
376
|
+
也可以通过 Podfile.lock 中的 `SPEC REPOS` 字段,查看哪些组件采用了源码版本,哪些采用了二进制版本:
|
377
|
+
|
378
|
+
```yaml
|
379
|
+
...
|
380
|
+
SPEC REPOS:
|
381
|
+
"git@git.2dfire.net:ios/cocoapods-spec-binary.git":
|
382
|
+
- AFNetworking
|
383
|
+
- Aspects
|
384
|
+
- CocoaSecurity
|
385
|
+
- DACircularProgress
|
386
|
+
...
|
387
|
+
"git@git.2dfire.net:ios/cocoapods-spec.git":
|
388
|
+
- ActivityForRestApp
|
389
|
+
- AMapFrameworks
|
390
|
+
- AssemblyComponent
|
391
|
+
...
|
392
|
+
...
|
393
|
+
```
|
394
|
+
|
395
|
+
#### use_binaries_with_spec_selector!
|
396
|
+
|
397
|
+
过滤出需要使用二进制版本组件。
|
398
|
+
|
399
|
+
假如开发者只需要 `YYModel` 的二进制版本,那么他可以在 Podfile 中添加以下代码:
|
400
|
+
|
401
|
+
```ruby
|
402
|
+
use_binaries_with_spec_selector! do |spec|
|
403
|
+
spec.name == 'YYModel'
|
404
|
+
end
|
405
|
+
```
|
406
|
+
|
407
|
+
一个实际应用是,三方组件采用二进制版本,团队编写的组件依旧采用源码版本。如果三方组件都在 `cocoapods-repo` 组下,就可以使用以下代码过滤出三方组件:
|
408
|
+
|
409
|
+
```ruby
|
410
|
+
use_binaries_with_spec_selector! do |spec|
|
411
|
+
git = spec.source && spec.source['git']
|
412
|
+
git && git.include?('cocoapods-repo')
|
413
|
+
end
|
414
|
+
```
|
415
|
+
|
416
|
+
#### set_use_source_pods
|
417
|
+
|
418
|
+
设置使用源码版本的组件。
|
419
|
+
|
420
|
+
实际开发中,可能需要查看 YYModel 组件的源码,这时候可以这么设置:
|
421
|
+
|
422
|
+
```ruby
|
423
|
+
set_use_source_pods ['YYModel']
|
424
|
+
```
|
425
|
+
|
426
|
+
#### 其他设置
|
427
|
+
|
428
|
+
插件默认开启多线程下载组件资源,如果要禁用这个功能,Podfile 添加以下代码即可:
|
429
|
+
|
430
|
+
```ruby
|
431
|
+
install! 'cocoapods', { install_with_multi_threads: true }
|
432
|
+
```
|
23
433
|
|
24
|
-
$ pod spec bin POD_NAME
|
@@ -19,9 +19,9 @@ module Pod
|
|
19
19
|
[
|
20
20
|
['--binary', '发布组件的二进制版本'],
|
21
21
|
['--template-podspec=A.binary-template.podspec', '生成拥有 subspec 的二进制 spec 需要的模版 podspec, 插件会更改 version 和 source'],
|
22
|
-
['--code-dependencies', '使用源码依赖进行 lint'],
|
23
|
-
['--loose-options', '添加宽松的 options, 包括 --use-libraries (可能会造成 entry point (start) undefined)'],
|
24
22
|
['--reserve-created-spec', '保留生成的二进制 spec 文件'],
|
23
|
+
['--code-dependencies', '使用源码依赖进行 lint'],
|
24
|
+
['--loose-options', '添加宽松的 options, 包括 --use-libraries (可能会造成 entry point (start) undefined)'],s
|
25
25
|
].concat(Pod::Command::Repo::Push.options).concat(super).uniq
|
26
26
|
end
|
27
27
|
|
@@ -32,7 +32,7 @@ module Pod
|
|
32
32
|
@installed_specs = []
|
33
33
|
pods_to_install = sandbox_state.added | sandbox_state.changed
|
34
34
|
title_options = { :verbose_prefix => '-> '.green }
|
35
|
-
Parallel.each(root_specs.sort_by(&:name), in_threads:
|
35
|
+
Parallel.each(root_specs.sort_by(&:name), in_threads: 4) do |spec|
|
36
36
|
if pods_to_install.include?(spec.name)
|
37
37
|
if sandbox_state.changed.include?(spec.name) && sandbox.manifest
|
38
38
|
previous = sandbox.manifest.version(spec.name)
|
@@ -57,7 +57,7 @@ module Pod
|
|
57
57
|
title_options = { :verbose_prefix => '-> '.green }
|
58
58
|
# 多进程下载,多线程时 log 会显著交叉,多进程好点,但是多进程需要利用文件锁对 cache 进行保护
|
59
59
|
# in_processes: 10
|
60
|
-
Parallel.each(root_specs.sort_by(&:name), in_threads:
|
60
|
+
Parallel.each(root_specs.sort_by(&:name), in_threads: 4) do |spec|
|
61
61
|
if pods_to_install.include?(spec.name)
|
62
62
|
if sandbox_state.changed.include?(spec.name) && sandbox.manifest
|
63
63
|
current_version = spec.version
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-bin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tripleCC
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parallel
|