cocoapods-bindyf 0.1.29.3
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 +7 -0
- data/.gitignore +4 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +104 -0
- data/LICENSE.txt +22 -0
- data/README.md +567 -0
- data/Rakefile +13 -0
- data/cocoapods-bin.gemspec +27 -0
- data/cocoapods-bindyf-0.1.29.2.gem +0 -0
- data/debug_install.sh +8 -0
- data/lib/cocoapods-bin.rb +4 -0
- data/lib/cocoapods-bin/command.rb +3 -0
- data/lib/cocoapods-bin/command/bin.rb +60 -0
- data/lib/cocoapods-bin/command/bin/archive.rb +130 -0
- data/lib/cocoapods-bin/command/bin/init.rb +71 -0
- data/lib/cocoapods-bin/command/bin/lib.rb +14 -0
- data/lib/cocoapods-bin/command/bin/lib/lint.rb +69 -0
- data/lib/cocoapods-bin/command/bin/list.rb +50 -0
- data/lib/cocoapods-bin/command/bin/open.rb +61 -0
- data/lib/cocoapods-bin/command/bin/repo.rb +15 -0
- data/lib/cocoapods-bin/command/bin/repo/push.rb +124 -0
- data/lib/cocoapods-bin/command/bin/repo/update.rb +42 -0
- data/lib/cocoapods-bin/command/bin/search.rb +69 -0
- data/lib/cocoapods-bin/command/bin/spec.rb +15 -0
- data/lib/cocoapods-bin/command/bin/spec/create.rb +75 -0
- data/lib/cocoapods-bin/command/bin/spec/lint.rb +119 -0
- data/lib/cocoapods-bin/command/bin/umbrella.rb +55 -0
- data/lib/cocoapods-bin/config/config.rb +80 -0
- data/lib/cocoapods-bin/config/config_asker.rb +58 -0
- data/lib/cocoapods-bin/gem_version.rb +11 -0
- data/lib/cocoapods-bin/helpers.rb +5 -0
- data/lib/cocoapods-bin/helpers/framework.rb +66 -0
- data/lib/cocoapods-bin/helpers/framework_builder.rb +190 -0
- data/lib/cocoapods-bin/helpers/sources_helper.rb +33 -0
- data/lib/cocoapods-bin/helpers/spec_creator.rb +147 -0
- data/lib/cocoapods-bin/helpers/spec_files_helper.rb +77 -0
- data/lib/cocoapods-bin/native.rb +20 -0
- data/lib/cocoapods-bin/native/acknowledgements.rb +27 -0
- data/lib/cocoapods-bin/native/analyzer.rb +53 -0
- data/lib/cocoapods-bin/native/installation_options.rb +26 -0
- data/lib/cocoapods-bin/native/installer.rb +115 -0
- data/lib/cocoapods-bin/native/linter.rb +26 -0
- data/lib/cocoapods-bin/native/path_source.rb +33 -0
- data/lib/cocoapods-bin/native/pod_source_installer.rb +19 -0
- data/lib/cocoapods-bin/native/podfile.rb +79 -0
- data/lib/cocoapods-bin/native/podfile_env.rb +36 -0
- data/lib/cocoapods-bin/native/podspec_finder.rb +25 -0
- data/lib/cocoapods-bin/native/resolver.rb +199 -0
- data/lib/cocoapods-bin/native/sandbox_analyzer.rb +34 -0
- data/lib/cocoapods-bin/native/source.rb +35 -0
- data/lib/cocoapods-bin/native/sources_manager.rb +20 -0
- data/lib/cocoapods-bin/native/specification.rb +31 -0
- data/lib/cocoapods-bin/native/validator.rb +16 -0
- data/lib/cocoapods-bin/source_provider_hook.rb +39 -0
- data/lib/cocoapods_plugin.rb +5 -0
- data/spec/command/bin_spec.rb +12 -0
- data/spec/spec_helper.rb +50 -0
- metadata +173 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 02c242564e5d1a24ecc012762e57074c3be35c84093182b121fe69222d17d6cb
|
4
|
+
data.tar.gz: b2998466d1bbba761371d520f2f09bdb350483e24cfbcfc40a3d1f741fa9e9bf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 42329dbee1755d9c5a75b20a691f1d0e588cc16e5b00effb30c2f92fb10f27d4a788377a1c3d8fb23d84bdbb23abbcb6e4608d5a3910412975bbdef6d9530d3d
|
7
|
+
data.tar.gz: b4505ddefc21e3a8d9993bdfb75c147fe66f14a840854b0bdff1196e7a13379f642b0a47a59910f207845910622c490d9685c6931ad4f7f23a0380f0e8deb028
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
cocoapods-bin (0.1.28)
|
5
|
+
cocoapods (~> 1.4)
|
6
|
+
cocoapods-generate (~> 1.4)
|
7
|
+
parallel
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
CFPropertyList (3.0.1)
|
13
|
+
activesupport (4.2.11.1)
|
14
|
+
i18n (~> 0.7)
|
15
|
+
minitest (~> 5.1)
|
16
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
17
|
+
tzinfo (~> 1.1)
|
18
|
+
atomos (0.1.3)
|
19
|
+
bacon (1.2.0)
|
20
|
+
claide (1.0.3)
|
21
|
+
cocoapods (1.7.1)
|
22
|
+
activesupport (>= 4.0.2, < 5)
|
23
|
+
claide (>= 1.0.2, < 2.0)
|
24
|
+
cocoapods-core (= 1.7.1)
|
25
|
+
cocoapods-deintegrate (>= 1.0.3, < 2.0)
|
26
|
+
cocoapods-downloader (>= 1.2.2, < 2.0)
|
27
|
+
cocoapods-plugins (>= 1.0.0, < 2.0)
|
28
|
+
cocoapods-search (>= 1.0.0, < 2.0)
|
29
|
+
cocoapods-stats (>= 1.0.0, < 2.0)
|
30
|
+
cocoapods-trunk (>= 1.3.1, < 2.0)
|
31
|
+
cocoapods-try (>= 1.1.0, < 2.0)
|
32
|
+
colored2 (~> 3.1)
|
33
|
+
escape (~> 0.0.4)
|
34
|
+
fourflusher (>= 2.2.0, < 3.0)
|
35
|
+
gh_inspector (~> 1.0)
|
36
|
+
molinillo (~> 0.6.6)
|
37
|
+
nap (~> 1.0)
|
38
|
+
ruby-macho (~> 1.4)
|
39
|
+
xcodeproj (>= 1.8.2, < 2.0)
|
40
|
+
cocoapods-core (1.7.1)
|
41
|
+
activesupport (>= 4.0.2, < 6)
|
42
|
+
fuzzy_match (~> 2.0.4)
|
43
|
+
nap (~> 1.0)
|
44
|
+
cocoapods-deintegrate (1.0.4)
|
45
|
+
cocoapods-disable-podfile-validations (0.1.1)
|
46
|
+
cocoapods-downloader (1.2.2)
|
47
|
+
cocoapods-generate (1.6.0)
|
48
|
+
cocoapods-disable-podfile-validations (~> 0.1.1)
|
49
|
+
cocoapods-plugins (1.0.0)
|
50
|
+
nap
|
51
|
+
cocoapods-search (1.0.0)
|
52
|
+
cocoapods-stats (1.1.0)
|
53
|
+
cocoapods-trunk (1.4.1)
|
54
|
+
nap (>= 0.8, < 2.0)
|
55
|
+
netrc (~> 0.11)
|
56
|
+
cocoapods-try (1.1.0)
|
57
|
+
colored2 (3.1.2)
|
58
|
+
concurrent-ruby (1.1.5)
|
59
|
+
escape (0.0.4)
|
60
|
+
fourflusher (2.3.1)
|
61
|
+
fuzzy_match (2.0.4)
|
62
|
+
gh_inspector (1.1.3)
|
63
|
+
i18n (0.9.5)
|
64
|
+
concurrent-ruby (~> 1.0)
|
65
|
+
metaclass (0.0.4)
|
66
|
+
minitest (5.12.1)
|
67
|
+
mocha (1.9.0)
|
68
|
+
metaclass (~> 0.0.1)
|
69
|
+
mocha-on-bacon (0.2.3)
|
70
|
+
mocha (>= 0.13.0)
|
71
|
+
molinillo (0.6.6)
|
72
|
+
nanaimo (0.2.6)
|
73
|
+
nap (1.1.0)
|
74
|
+
netrc (0.11.0)
|
75
|
+
parallel (1.19.1)
|
76
|
+
prettybacon (0.0.2)
|
77
|
+
bacon (~> 1.2)
|
78
|
+
rake (13.0.0)
|
79
|
+
ruby-macho (1.4.0)
|
80
|
+
thread_safe (0.3.6)
|
81
|
+
tzinfo (1.2.5)
|
82
|
+
thread_safe (~> 0.1)
|
83
|
+
xcodeproj (1.12.0)
|
84
|
+
CFPropertyList (>= 2.3.3, < 4.0)
|
85
|
+
atomos (~> 0.1.3)
|
86
|
+
claide (>= 1.0.2, < 2.0)
|
87
|
+
colored2 (~> 3.1)
|
88
|
+
nanaimo (~> 0.2.6)
|
89
|
+
|
90
|
+
PLATFORMS
|
91
|
+
ruby
|
92
|
+
|
93
|
+
DEPENDENCIES
|
94
|
+
bacon
|
95
|
+
bundler (~> 1.3)
|
96
|
+
cocoapods (= 1.7.1)
|
97
|
+
cocoapods-bin!
|
98
|
+
mocha
|
99
|
+
mocha-on-bacon
|
100
|
+
prettybacon
|
101
|
+
rake
|
102
|
+
|
103
|
+
BUNDLED WITH
|
104
|
+
1.17.3
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2018 tripleCC <triplec.linux@gmail.com>
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,567 @@
|
|
1
|
+
# cocoapods-bin-framework
|
2
|
+
|
3
|
+
组件二进制化插件。
|
4
|
+
|
5
|
+
### 注意:
|
6
|
+
|
7
|
+
本版本基于 `cococapod-bin` 改造,用于打包 动态framework
|
8
|
+
1. 使用本仓库,需要卸载 cococapod-bin
|
9
|
+
1. 需要去掉`s.static_framework = true`
|
10
|
+
2. 不建议包含 subspec,没有经过测试
|
11
|
+
3. 支持打包 swift 库 (在自己公司测试了一个 swift 库,使用没有问题)
|
12
|
+
4. 用于解决带有这个标记的情况 `use_frameworks!`, 以及改成静态库后资源路径的问题
|
13
|
+
|
14
|
+
|
15
|
+
> 安装本改造版本 `cocoapods-bin`:
|
16
|
+
|
17
|
+
$ gem install cocoapods-bindyf
|
18
|
+
|
19
|
+
> Podfile 中使用:
|
20
|
+
|
21
|
+
$ plugin 'cocoapods-bindyf'
|
22
|
+
|
23
|
+
|
24
|
+
其余配置命令按照原版操作即可
|
25
|
+
|
26
|
+
---
|
27
|
+
|
28
|
+
[基于 CocoaPods 的组件二进制化实践](https://triplecc.github.io/2019/01/21/%E5%9F%BA%E4%BA%8ECocoaPods%E7%9A%84%E7%BB%84%E4%BB%B6%E4%BA%8C%E8%BF%9B%E5%88%B6%E5%8C%96%E5%AE%9E%E8%B7%B5/)
|
29
|
+
|
30
|
+
[Demo 工程](https://github.com/for-example-test/cocoapods-bin-example)
|
31
|
+
|
32
|
+
## 更新
|
33
|
+
|
34
|
+
#### 0.1.28
|
35
|
+
|
36
|
+
新增本地组件依赖配置文件 BinPodfile ,
|
37
|
+
|
38
|
+
场景: 不希望把本地采用的源码/二进制配置传到远程仓库。
|
39
|
+
|
40
|
+
使用: 在 Podfile 同级目录下创建 BinPodfile ,并将其加入 .gitignore 。BinPodfile 中的配置选项优先级比 Podfile 高,支持和 Podfile 相同的配置语句,如 :
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
# BinPodfile
|
44
|
+
|
45
|
+
use_binaries!
|
46
|
+
set_use_source_pods ['YYModel']
|
47
|
+
|
48
|
+
```
|
49
|
+
|
50
|
+
|
51
|
+
## 概要
|
52
|
+
|
53
|
+
本插件所关联的组件二进制化策略:
|
54
|
+
|
55
|
+
预先将打包成 `.a` 或者 `.framework` 的组件(目前接入此插件必须使用 `.framework`,最好是静态 framework)保存到静态服务器上,并在 `install` 时,去下载组件对应的二进制版本,以减少组件编译时间,达到加快 App 打包、组件 lint、组件发布等操作的目的。
|
56
|
+
|
57
|
+
使用本插件需要提供以下资源:
|
58
|
+
|
59
|
+
- 静态资源服务器(可参考 [binary-server](https://github.com/tripleCC/binary-server.git))
|
60
|
+
- 源码私有源(保存组件源码版本 podspec)
|
61
|
+
- 二进制私有源(保存组件二进制版本 podspec)
|
62
|
+
|
63
|
+
在所有组件都依赖二进制版本的情况下,本插件支持切换指定组件的依赖版本。
|
64
|
+
|
65
|
+
推荐结合 GitLab CI 使用本插件,可以实现自动打包发布,并显著减少其 pipeline 耗时。关于 GitLab CI 的实践,可以参考 [火掌柜 iOS 团队 GitLab CI 集成实践](https://triplecc.github.io/2018/06/23/2018-06-23-ji-gitlabcide-ci-shi-jian/)。虽然后来对部分 stage 和脚本都进行了优化,但总体构建思路还是没变的。
|
66
|
+
|
67
|
+
## 准备工作
|
68
|
+
|
69
|
+
安装原版 `cocoapods-bin`:
|
70
|
+
|
71
|
+
$ gem install cocoapods-bindyf
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
初始化插件:
|
76
|
+
|
77
|
+
```shell
|
78
|
+
➜ ~ pod bin init
|
79
|
+
|
80
|
+
开始设置二进制化初始信息.
|
81
|
+
所有的信息都会保存在 /Users/songruiwang/.cocoapods/bin.yml 文件中.
|
82
|
+
你可以在对应目录下手动添加编辑该文件. 文件包含的配置信息样式如下:
|
83
|
+
|
84
|
+
---
|
85
|
+
code_repo_url: git@git.xxxxxx.net:ios/cocoapods-spec.git
|
86
|
+
binary_repo_url: git@git.xxxxxx.net:ios/cocoapods-spec-binary.git
|
87
|
+
binary_download_url: http://iosframeworkserver-shopkeeperclient.app.2dfire.com/download/%s/%s.zip
|
88
|
+
download_file_type: zip
|
89
|
+
|
90
|
+
|
91
|
+
源码私有源 Git 地址
|
92
|
+
旧值:git@git.xxxxxx.net:ios/cocoapods-spec.git
|
93
|
+
>
|
94
|
+
```
|
95
|
+
|
96
|
+
按提示输入源码私有源、二进制私有源、二进制下载地址、下载文件类型后,插件就配置完成了。其中 `binary_download_url` 需要预留组件名称与组件版本占位符,插件内部会依次替换 `%s` 为相应组件的值。
|
97
|
+
|
98
|
+
`cococapod-bin` 也支持从 url 下载配置文件,方便对多台机器进行配置:
|
99
|
+
|
100
|
+
```shell
|
101
|
+
➜ ~ pod bin init --bin-url=http://git.xxxxxx.net/qingmu/cocoapods-tdfire-binary-config/raw/master/bin.yml
|
102
|
+
```
|
103
|
+
|
104
|
+
配置文件模版内容如下,根据不同团队的需求定制即可:
|
105
|
+
|
106
|
+
```yaml
|
107
|
+
---
|
108
|
+
code_repo_url: git@git.xxxxxx.net:ios/cocoapods-spec.git
|
109
|
+
binary_repo_url: git@git.xxxxxx.net:ios/cocoapods-spec-binary.git
|
110
|
+
binary_download_url: http://iosframeworkserver-shopkeeperclient.app.2dfire.com/download/%s/%s.zip
|
111
|
+
download_file_type: zip
|
112
|
+
```
|
113
|
+
|
114
|
+
配置时,不需要手动添加源码和二进制私有源的 repo,插件在找不到对应 repo 时会主动 clone。
|
115
|
+
|
116
|
+
插件配置完后,就可以部署静态资源服务器了。对于静态资源服务器,这里不做赘述,只提示一点:在生成二进制 podspec 时,插件会根据 `download_file_type` 设置 source 的 `:type` 字段。在下载 http/https 资源时,CocoaPods 会根据 `:type` 字段的类型采取相应的解压方式,如果设置错误就会抛错。这里提到了 **二进制 podspec 的自动生成**,后面会详细介绍。
|
117
|
+
|
118
|
+
这里额外说下打包工具 [cocoapods-packager](https://github.com/CocoaPods/cocoapods-packager) 和 [Carthage](https://github.com/Carthage/Carthage/issues) ,前者可以通过 podspec 进行打包,只要保证 lint 通过了,就可以打成 `.framework`,很方便,但是作者几乎不维护了,后者需要结合组件工程。具体使用哪个可以结合自身团队,甚至可以自己写打包脚本,或者使用本插件的打包命令。
|
119
|
+
|
120
|
+
## 使用插件
|
121
|
+
|
122
|
+
接入二进制版本后,常规的发布流程需要做如下变更:
|
123
|
+
|
124
|
+
```shell
|
125
|
+
# 1 打出二进制产物 && 提交产物至静态文件服务器
|
126
|
+
pod bin archive YOUR_OPTIONS
|
127
|
+
curl xxxxxxx
|
128
|
+
|
129
|
+
# 2.1 发布二进制 podspec
|
130
|
+
pod bin repo push --binary YOUR_OPTIONS
|
131
|
+
|
132
|
+
# 2.2 发布源码 podspec
|
133
|
+
pod bin repo push YOUR_OPTIONS
|
134
|
+
```
|
135
|
+
|
136
|
+
如果团队内部集成了 CI 平台,那么上面的每大步都可以对应一个 CI stage,源码和二进制版本可并行发布,对应一个 stage 中的两个 job。
|
137
|
+
|
138
|
+
|
139
|
+
### 基本信息
|
140
|
+
|
141
|
+
`cocoapods-bin` 命令行信息可以输入以下命令查看:
|
142
|
+
|
143
|
+
```shell
|
144
|
+
➜ ~ pod bin --help
|
145
|
+
Usage:
|
146
|
+
|
147
|
+
$ pod bin [COMMAND]
|
148
|
+
|
149
|
+
组件二进制化插件。利用源码私有源与二进制私有源实现对组件依赖类型的切换。
|
150
|
+
|
151
|
+
Commands:
|
152
|
+
+ archive 将组件归档为静态 framework.
|
153
|
+
+ init 初始化插件.
|
154
|
+
+ lib 管理二进制 pod.
|
155
|
+
+ list 展示二进制 pods .
|
156
|
+
> open 打开 workspace 工程.
|
157
|
+
+ repo 管理 spec 仓库.
|
158
|
+
+ search 查找二进制 spec.
|
159
|
+
+ spec 管理二进制 spec.
|
160
|
+
+ umbrella 生成伞头文件 .
|
161
|
+
```
|
162
|
+
|
163
|
+
### 构建二进制产物
|
164
|
+
|
165
|
+
```shell
|
166
|
+
➜ ~ pod bin archive --help
|
167
|
+
Usage:
|
168
|
+
|
169
|
+
$ pod bin archive [NAME.podspec]
|
170
|
+
|
171
|
+
将组件归档为静态 framework,仅支持 iOS 平台 此静态 framework 不包含依赖组件的 symbol
|
172
|
+
|
173
|
+
Options:
|
174
|
+
|
175
|
+
--code-dependencies 使用源码依赖
|
176
|
+
--allow-prerelease 允许使用 prerelease 的版本
|
177
|
+
--use-modular-headers 使用 modular headers (modulemap)
|
178
|
+
--no-clean 保留构建中间产物
|
179
|
+
--no-zip 不压缩静态 framework 为 zip
|
180
|
+
...
|
181
|
+
```
|
182
|
+
|
183
|
+
`pod bin archive` 会根据 podspec 文件构建静态 framework ,此静态 framework 不会包含依赖组件的符号信息。命令内部利用 [cocoapods-generate](https://github.com/square/cocoapods-generate) 插件生成工程,并移植了 [cocoapods-packager](https://github.com/CocoaPods/cocoapods-packager) 插件的部分打包功能,以构建前者生成的工程,默认条件下,命令会生成一个 zip 压缩包。
|
184
|
+
|
185
|
+
### 二进制 podspec
|
186
|
+
|
187
|
+
`cocoapods-bin` 针对一个组件,同时使用了两种 podspec,分别为源码 podspec 和二进制 podspec,这种方式在没有工具支撑的情况下,势必会增加开发者维护组件的工作量。做为开发者来说,我是不希望同时维护两套 podspec 的。为了解决这个问题, 插件提供了自动生成二进制 podspec 功能,开发者依旧只需要关心源码 podspec 即可。
|
188
|
+
|
189
|
+
一般来说,在接入插件前,组件源码 podspec 是已经存在的,所以我们只需要向二进制私有源推送组件的二进制 podspec 即可。如果有条件的话,二进制和源码 podspec 的发布可以走 GitLab CI ,这也是我推荐的做法。
|
190
|
+
|
191
|
+
下面介绍下和二进制 podspec 相关的 `cocoapods-bin` 命令。
|
192
|
+
|
193
|
+
#### pod bin spec create
|
194
|
+
|
195
|
+
```shell
|
196
|
+
➜ ~ pod bin spec create --help
|
197
|
+
Usage:
|
198
|
+
|
199
|
+
$ pod bin spec create
|
200
|
+
|
201
|
+
根据源码 podspec 文件,创建对应的二进制 podspec 文件.
|
202
|
+
|
203
|
+
Options:
|
204
|
+
|
205
|
+
--platforms=ios 生成二进制 spec 支持的平台
|
206
|
+
--template-podspec=A.binary-template.podspec 生成拥有 subspec 的二进制 spec 需要的模版
|
207
|
+
podspec, 插件会更改 version 和 source
|
208
|
+
--no-overwrite 不允许覆盖
|
209
|
+
...
|
210
|
+
```
|
211
|
+
|
212
|
+
`pod bin spec create` 会根据源码 podspec ,创建出二进制 podspec 文件。如果组件存在 subspec ,需要开发者提供 podspec 模版信息,以生成二进制 podspec。插件会根据源码 podspec 更改模版中的 version 字段,并且根据插件配置的 `binary_download_url` 生成 source 字段,最终生成二进制 podspec。
|
213
|
+
|
214
|
+
以 A 组件举例,如果 A 的 podspec 如下:
|
215
|
+
|
216
|
+
```ruby
|
217
|
+
Pod::Spec.new do |s|
|
218
|
+
s.name = 'A'
|
219
|
+
s.version = '0.1.0'
|
220
|
+
s.summary = 'business A short description of A.'
|
221
|
+
s.description = <<-DESC
|
222
|
+
TODO: Add long description of the pod here.
|
223
|
+
DESC
|
224
|
+
s.homepage = 'http://git.2dfire-inc.com/ios/A'
|
225
|
+
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
226
|
+
s.author = { 'qingmu' => 'qingmu@2dfire.com' }
|
227
|
+
s.source = { :git => 'http://git.2dfire-inc.com/qiandaojiang/A.git', :tag => s.version.to_s }
|
228
|
+
s.ios.deployment_target = '8.0'
|
229
|
+
s.source_files = 'A/Classes/**/*'
|
230
|
+
s.public_header_files = 'A/Classes/**/*.{h}'
|
231
|
+
s.resource_bundles = {
|
232
|
+
'A' => ['A/Assets/*']
|
233
|
+
}
|
234
|
+
end
|
235
|
+
```
|
236
|
+
|
237
|
+
那么生成的 `A.binary.podspec.json` 如下:
|
238
|
+
|
239
|
+
```json
|
240
|
+
{
|
241
|
+
"name": "A",
|
242
|
+
"version": "0.1.0",
|
243
|
+
"summary": "business A short description of A.",
|
244
|
+
"description": "TODO: Add long description of the pod here.",
|
245
|
+
"homepage": "http://git.2dfire-inc.com/ios/A",
|
246
|
+
"license": {
|
247
|
+
"type": "MIT",
|
248
|
+
"file": "LICENSE"
|
249
|
+
},
|
250
|
+
"authors": {
|
251
|
+
"qingmu": "qingmu@2dfire.com"
|
252
|
+
},
|
253
|
+
"source": {
|
254
|
+
"http": "http://iosframeworkserver-shopkeeperclient.app.2dfire.com/download/A/0.1.0.zip",
|
255
|
+
"type": "zip"
|
256
|
+
},
|
257
|
+
"platforms": {
|
258
|
+
"ios": "8.0"
|
259
|
+
},
|
260
|
+
"source_files": [
|
261
|
+
"A.framework/Headers/*",
|
262
|
+
"A.framework/Versions/A/Headers/*"
|
263
|
+
],
|
264
|
+
"public_header_files": [
|
265
|
+
"A.framework/Headers/*",
|
266
|
+
"A.framework/Versions/A/Headers/*"
|
267
|
+
],
|
268
|
+
"vendored_frameworks": "A.framework",
|
269
|
+
"resources": [
|
270
|
+
"A.framework/Resources/*.bundle",
|
271
|
+
"A.framework/Versions/A/Resources/*.bundle"
|
272
|
+
]
|
273
|
+
}
|
274
|
+
```
|
275
|
+
|
276
|
+
如果 A 拥有 subspec:
|
277
|
+
|
278
|
+
```ruby
|
279
|
+
Pod::Spec.new do |s|
|
280
|
+
s.name = 'A'
|
281
|
+
s.version = '0.1.0'
|
282
|
+
s.summary = 'business A short description of A.'
|
283
|
+
s.description = <<-DESC
|
284
|
+
TODO: Add long description of the pod here.
|
285
|
+
DESC
|
286
|
+
s.homepage = 'http://git.2dfire-inc.com/ios/A'
|
287
|
+
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
288
|
+
s.author = { 'qingmu' => 'qingmu@2dfire.com' }
|
289
|
+
s.source = { :git => 'http://git.2dfire-inc.com/qiandaojiang/A.git', :tag => s.version.to_s }
|
290
|
+
s.ios.deployment_target = '8.0'
|
291
|
+
s.source_files = 'A/Classes/**/*'
|
292
|
+
s.public_header_files = 'A/Classes/**/*.{h}'
|
293
|
+
s.resource_bundles = {
|
294
|
+
'A' => ['A/Assets/*']
|
295
|
+
}
|
296
|
+
s.subspec 'B' do |ss|
|
297
|
+
ss.dependency 'YYModel'
|
298
|
+
ss.source_files = 'A/Classes/**/*'
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
```
|
303
|
+
|
304
|
+
那么就需要开发者提供 `A.binary-template.podspec`(此模版中的写法假定组件的所有 subspec 都打进一个 `.framework` 里,如果 subpsec 都有属于自己的 `.framework` ,就可以采用其他写法。),**这里要注意源码版本 subspec 集合需要为二进制版本 subspec 集合的子集,否则会出现源码拉取失败或抛出 subspec 不存在错误的情况**:
|
305
|
+
|
306
|
+
```ruby
|
307
|
+
Pod::Spec.new do |s|
|
308
|
+
s.name = 'A'
|
309
|
+
s.summary = 'business A short description of A.'
|
310
|
+
s.description = <<-DESC
|
311
|
+
TODO: Add long description of the pod here.
|
312
|
+
DESC
|
313
|
+
s.homepage = 'http://git.2dfire-inc.com/ios/A'
|
314
|
+
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
315
|
+
s.author = { 'qingmu' => 'qingmu@2dfire.com' }
|
316
|
+
s.ios.deployment_target = '8.0'
|
317
|
+
|
318
|
+
s.subspec "Binary" do |ss|
|
319
|
+
ss.vendored_frameworks = "#{s.name}.framework"
|
320
|
+
ss.source_files = "#{s.name}.framework/Headers/*", "#{s.name}.framework/Versions/A/Headers/*"
|
321
|
+
ss.public_header_files = "#{s.name}.framework/Headers/*", "#{s.name}.framework/Versions/A/Headers/*"
|
322
|
+
# 结合实际打包后的资源产出文件类型编写
|
323
|
+
ss.resources = "#{s.name}.framework/Resources/*.{bundle}", "#{s.name}.framework/Versions/A/Resources/*.{bundle}"
|
324
|
+
ss.dependency 'YYModel'
|
325
|
+
end
|
326
|
+
|
327
|
+
s.subspec 'B' do |ss|
|
328
|
+
ss.dependency "#{s.name}/Binary"
|
329
|
+
end
|
330
|
+
end
|
331
|
+
|
332
|
+
```
|
333
|
+
|
334
|
+
最终生成的二进制 podspec 如下:
|
335
|
+
|
336
|
+
```json
|
337
|
+
{
|
338
|
+
"name": "A",
|
339
|
+
"summary": "business A short description of A.",
|
340
|
+
"description": "TODO: Add long description of the pod here.",
|
341
|
+
"homepage": "http://git.2dfire-inc.com/ios/A",
|
342
|
+
"license": {
|
343
|
+
"type": "MIT",
|
344
|
+
"file": "LICENSE"
|
345
|
+
},
|
346
|
+
"authors": {
|
347
|
+
"qingmu": "qingmu@2dfire.com"
|
348
|
+
},
|
349
|
+
"platforms": {
|
350
|
+
"ios": "8.0"
|
351
|
+
},
|
352
|
+
"version": "0.1.0",
|
353
|
+
"source": {
|
354
|
+
"http": "http://iosframeworkserver-shopkeeperclient.app.2dfire.com/download/A/0.1.0.zip",
|
355
|
+
"type": "zip"
|
356
|
+
},
|
357
|
+
"subspecs": [
|
358
|
+
{
|
359
|
+
"name": "Binary",
|
360
|
+
"vendored_frameworks": "A.framework",
|
361
|
+
"source_files": [
|
362
|
+
"A.framework/Headers/*",
|
363
|
+
"A.framework/Versions/A/Headers/*"
|
364
|
+
],
|
365
|
+
"public_header_files": [
|
366
|
+
"A.framework/Headers/*",
|
367
|
+
"A.framework/Versions/A/Headers/*"
|
368
|
+
],
|
369
|
+
"resources": [
|
370
|
+
"A.framework/Resources/*.{bundle}",
|
371
|
+
"A.framework/Versions/A/Resources/*.{bundle}"
|
372
|
+
],
|
373
|
+
"dependencies": {
|
374
|
+
"YYModel": [
|
375
|
+
|
376
|
+
]
|
377
|
+
}
|
378
|
+
},
|
379
|
+
{
|
380
|
+
"name": "B",
|
381
|
+
"dependencies": {
|
382
|
+
"A/Binary": [
|
383
|
+
|
384
|
+
]
|
385
|
+
}
|
386
|
+
}
|
387
|
+
]
|
388
|
+
}
|
389
|
+
```
|
390
|
+
|
391
|
+
#### pod bin spec lint
|
392
|
+
|
393
|
+
```shell
|
394
|
+
➜ ~ pod bin spec lint --help
|
395
|
+
Usage:
|
396
|
+
|
397
|
+
$ pod bin spec lint [NAME.podspec|DIRECTORY|http://PATH/NAME.podspec ...]
|
398
|
+
|
399
|
+
spec lint 二进制组件 / 源码组件
|
400
|
+
|
401
|
+
Options:
|
402
|
+
|
403
|
+
--binary lint 组件的二进制版本
|
404
|
+
--template-podspec=A.binary-template.podspec 生成拥有 subspec 的二进制 spec 需要的模版
|
405
|
+
podspec, 插件会更改 version 和 source
|
406
|
+
--reserve-created-spec 保留生成的二进制 spec 文件
|
407
|
+
--code-dependencies 使用源码依赖进行 lint
|
408
|
+
--loose-options 添加宽松的 options, 包括 --use-libraries
|
409
|
+
(可能会造成 entry point (start)
|
410
|
+
undefined)
|
411
|
+
...
|
412
|
+
```
|
413
|
+
|
414
|
+
`pod bin spec lint` 默认使用二进制依赖进行 lint,在添加 `--binary` 会去 lint 当前组件的二进制 podspec(动态生成)。在添加 `--code-dependencies` 将会使用源码依赖进行 lint ,个人推荐使用二进制依赖 lint,可以极大地减少编译时间。
|
415
|
+
|
416
|
+
#### pod bin repo push
|
417
|
+
|
418
|
+
```shell
|
419
|
+
|
420
|
+
➜ ~ pod bin repo push --help
|
421
|
+
Usage:
|
422
|
+
|
423
|
+
$ pod bin repo push [NAME.podspec]
|
424
|
+
|
425
|
+
发布二进制组件 / 源码组件
|
426
|
+
|
427
|
+
Options:
|
428
|
+
|
429
|
+
--binary 发布组件的二进制版本
|
430
|
+
--template-podspec=A.binary-template.podspec 生成拥有 subspec 的二进制 spec 需要的模版
|
431
|
+
podspec, 插件会更改 version 和 source
|
432
|
+
--reserve-created-spec 保留生成的二进制 spec 文件
|
433
|
+
--code-dependencies 使用源码依赖进行 lint
|
434
|
+
--loose-options 添加宽松的 options, 包括
|
435
|
+
--use-libraries (可能会造成 entry
|
436
|
+
point (start) undefined)
|
437
|
+
...
|
438
|
+
```
|
439
|
+
|
440
|
+
`pod bin repo push` 用来发布组件,其余特性和 `pod bin spec lint` 一致。
|
441
|
+
|
442
|
+
### Podfile DSL
|
443
|
+
|
444
|
+
首先,开发者需要在 Podfile 中需要使用 `plugin 'cocoapods-bin'` 语句引入插件 :
|
445
|
+
|
446
|
+
```ruby
|
447
|
+
plugin 'cocoapods-bin'
|
448
|
+
```
|
449
|
+
|
450
|
+
顺带可以删除 Podfile 中的 source ,因为插件内部会自动帮你添加两个私有源。
|
451
|
+
|
452
|
+
`cocoapods-bin `插件提供二进制相关的配置语句有 `use_binaries!`、`use_binaries_with_spec_selector!` 以及 `set_use_source_pods`,下面会分别介绍。
|
453
|
+
|
454
|
+
#### use_binaries!
|
455
|
+
|
456
|
+
全部组件使用二进制版本。
|
457
|
+
|
458
|
+
支持传入布尔值控制是否使用二进制版本,比如 DEBUG 包使用二进制版本,正式包使用源码版本,Podfile 关联语句可以这样写:
|
459
|
+
|
460
|
+
```ruby
|
461
|
+
use_binaries! (ENV['DEBUG'].nil? || ENV['DEBUG'] == 'true')
|
462
|
+
```
|
463
|
+
|
464
|
+
当组件没有二进制版本时,插件会强制工程依赖该组件的源码版本。开发者可以通过执行 `pod install--verbose` option ,在分析依赖步骤查看哪些组件没有二进制版本:
|
465
|
+
|
466
|
+
```shell
|
467
|
+
...
|
468
|
+
Resolving dependencies of `Podfile`
|
469
|
+
【AMapFrameworks | 0.0.4】组件无对应二进制版本 , 将采用源码依赖.
|
470
|
+
【ActivityForRestApp | 0.2.1】组件无对应二进制版本 , 将采用源码依赖.
|
471
|
+
【AssemblyComponent | 0.5.9】组件无对应二进制版本 , 将采用源码依赖.
|
472
|
+
【Bugly | 2.4.6】组件无对应二进制版本 , 将采用源码依赖.
|
473
|
+
【Celebi | 0.6.4】组件无对应二进制版本 , 将采用源码依赖.
|
474
|
+
【CocoaAsyncSocket/RunLoop | 7.4.3】组件无对应二进制版本 , 将采用源码依赖.
|
475
|
+
【CocoaLumberjack | 3.4.1】组件无对应二进制版本 , 将采用源码依赖.
|
476
|
+
【CocoaLumberjack/Default | 3.4.1】组件无对应二进制版本 , 将采用源码依赖.
|
477
|
+
【CocoaLumberjack/Extensions | 3.4.1】组件无对应二进制版本 , 将采用源码依赖.
|
478
|
+
【CodePush | 0.3.1】组件无对应二进制版本 , 将采用源码依赖.
|
479
|
+
【CodePush/Core | 0.3.1】组件无对应二进制版本 , 将采用源码依赖.
|
480
|
+
【CodePush/SSZipArchive | 0.3.1】组件无对应二进制版本 , 将采用源码依赖.
|
481
|
+
【ESExchangeSkin | 0.3.2】组件无对应二进制版本 , 将采用源码依赖.
|
482
|
+
...
|
483
|
+
```
|
484
|
+
|
485
|
+
也可以通过 Podfile.lock 中的 `SPEC REPOS` 字段,查看哪些组件采用了源码版本,哪些采用了二进制版本:
|
486
|
+
|
487
|
+
```yaml
|
488
|
+
...
|
489
|
+
SPEC REPOS:
|
490
|
+
"git@git.xxxxxx.net:ios/cocoapods-spec-binary.git":
|
491
|
+
- AFNetworking
|
492
|
+
- Aspects
|
493
|
+
- CocoaSecurity
|
494
|
+
- DACircularProgress
|
495
|
+
...
|
496
|
+
"git@git.xxxxxx.net:ios/cocoapods-spec.git":
|
497
|
+
- ActivityForRestApp
|
498
|
+
- AMapFrameworks
|
499
|
+
- AssemblyComponent
|
500
|
+
...
|
501
|
+
...
|
502
|
+
```
|
503
|
+
|
504
|
+
|
505
|
+
#### set_use_source_pods
|
506
|
+
|
507
|
+
设置使用源码版本的组件。
|
508
|
+
|
509
|
+
实际开发中,可能需要查看 YYModel 组件的源码,这时候可以这么设置:
|
510
|
+
|
511
|
+
```ruby
|
512
|
+
set_use_source_pods ['YYModel']
|
513
|
+
```
|
514
|
+
|
515
|
+
如果 CocoaPods 版本为 1.5.3 ,终端会输出以下内容,表示 YYModel 的参照源从二进制私有源切换到了源码私有源:
|
516
|
+
|
517
|
+
```shell
|
518
|
+
Analyzing dependencies
|
519
|
+
Fetching podspec for `A` from `../`
|
520
|
+
Downloading dependencies
|
521
|
+
Using A (0.1.0)
|
522
|
+
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`)
|
523
|
+
Generating Pods project
|
524
|
+
Integrating client project
|
525
|
+
Sending stats
|
526
|
+
Pod installation complete! There is 1 dependency from the Podfile and 2 total pods installed.
|
527
|
+
```
|
528
|
+
|
529
|
+
#### use_binaries_with_spec_selector!
|
530
|
+
|
531
|
+
过滤出需要使用二进制版本组件。
|
532
|
+
|
533
|
+
假如开发者只需要 `YYModel` 的二进制版本,那么他可以在 Podfile 中添加以下代码:
|
534
|
+
|
535
|
+
```ruby
|
536
|
+
use_binaries_with_spec_selector! do |spec|
|
537
|
+
spec.name == 'YYModel'
|
538
|
+
end
|
539
|
+
```
|
540
|
+
|
541
|
+
**需要注意的是,如果组件有 subspec ,使用组件名作为判断条件应如下**:
|
542
|
+
|
543
|
+
```ruby
|
544
|
+
use_binaries_with_spec_selector! do |spec|
|
545
|
+
spec.name.start_with? == '组件名'
|
546
|
+
end
|
547
|
+
```
|
548
|
+
|
549
|
+
如果像上个代码块一样,**直接对比组件名,则插件会忽略此组件的所有 subspec,导致资源拉取错误**,这种场景下,最好通过 `set_use_source_pods` 语句配置依赖。
|
550
|
+
|
551
|
+
一个实际应用是,三方组件采用二进制版本,团队编写的组件依旧采用源码版本。如果三方组件都在 `cocoapods-repo` 组下,就可以使用以下代码过滤出三方组件:
|
552
|
+
|
553
|
+
```ruby
|
554
|
+
use_binaries_with_spec_selector! do |spec|
|
555
|
+
git = spec.source && spec.source['git']
|
556
|
+
git && git.include?('cocoapods-repo')
|
557
|
+
end
|
558
|
+
```
|
559
|
+
|
560
|
+
#### 其他设置
|
561
|
+
|
562
|
+
插件默认开启多线程下载组件资源,如果要禁用这个功能,Podfile 添加以下代码即可:
|
563
|
+
|
564
|
+
```ruby
|
565
|
+
install! 'cocoapods', { install_with_multi_threads: false }
|
566
|
+
```
|
567
|
+
|