cocoapods-imy-bin 0.2.1 → 0.2.7

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
- SHA1:
3
- metadata.gz: c99d4590c1c6004926364bb52d7f91440241f103
4
- data.tar.gz: f3de8526a052828003e5d2eb797e474c21decc5d
2
+ SHA256:
3
+ metadata.gz: 9571b93573cfc8a24a73661aa4d8d0e27a13fdc797fef8d63cc5b5f1641f4031
4
+ data.tar.gz: 428ca79deaa2875849911dd1f52ffdb32906eabcc8445d9a5cafc75f8326031f
5
5
  SHA512:
6
- metadata.gz: fb547402fa37dea290961ca3c28c2706362e8ffb0dc8d17c2de4ce7ea8ca6242a501a1c8d6eb6985581e6d8d86be975e184dc9c916d991b8809e347bf268915a
7
- data.tar.gz: 6db6b055aa0d2c238cca049f33e19b2143db2e33c445995d35b22fa0f073f86e1180f0a312f20ce9f96b30151a06794fb84a6405980f88ee21af0e3d36bf0a7f
6
+ metadata.gz: a18e4e0f9693c4718fc07910e23b24e51723f77f73ac1afe282a2ee433fade499f4b744ebd9cbd75067fea4da470d91da5c5b44044d66cda282c68a0903597bb
7
+ data.tar.gz: 78b83b8d6ba156fde03afdd718a0c838deb4716d3e5474f88eba38ea351298d41d436b46e7b40e919cf2aa53298970482be2d7153f17fca8a305e262945ab4aa
data/README.md CHANGED
@@ -1,431 +1,351 @@
1
- # cocoapods-bin
1
+ # Cocoapods-imy-bin
2
2
 
3
- 组件二进制化插件。
3
+ ## 一、概要
4
4
 
5
- [基于 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/)
6
5
 
7
- [Demo 工程](https://github.com/for-example-test/cocoapods-bin-example)
6
+ cocoapods-imy-bin功能点:
8
7
 
9
- ## 更新
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命令),减少其他繁琐操作。支持任意个快捷键。
10
12
 
11
- #### 0.1.28
13
+ cocoapods-imy-bin插件所关联的组件二进制化策略:
12
14
 
13
- 新增本地组件依赖配置文件 BinPodfile
15
+ 预先将打包成 `.a` 的组件保存到静态服务器上,并在 `install` 时,去下载组件对应的二进制版本,以减少组件编译时间,达到加快 App 打包、组件发布等操作的目的。
14
16
 
15
- 场景: 不希望把本地采用的源码/二进制配置传到远程仓库。
17
+ 关于 插件具体的架构部署实践和更详细的资源,可以参考
16
18
 
17
- 使用: 在 Podfile 同级目录下创建 BinPodfile ,并将其加入 .gitignore 。BinPodfile 中的配置选项优先级比 Podfile 高,支持和 Podfile 相同的配置语句,如 :
19
+ > [iOS编译速度如何稳定提高10倍以上](https://www.jianshu.com/p/08cffdfa2885)
20
+ >
21
+ > [Demo](https://github.com/su350380433/cocoapods-imy-bin-demo)
22
+ >
18
23
 
19
- ```ruby
20
- # BinPodfile
21
24
 
22
- use_binaries!
23
- set_use_source_pods ['YYModel']
25
+ ## 二、准备工作
26
+
24
27
 
28
+
29
+ ### 1、安装插件
30
+
31
+ ```shell
32
+ sudo gem install cocoapods-imy-bin
25
33
  ```
26
34
 
27
35
 
28
- ## 概要
29
36
 
30
- 本插件所关联的组件二进制化策略:
37
+ ## 三、使用二进制组件
31
38
 
32
- 预先将打包成 `.a` 或者 `.framework` 的组件(目前接入此插件必须使用 `.framework`,最好是静态 framework)保存到静态服务器上,并在 `install` 时,去下载组件对应的二进制版本,以减少组件编译时间,达到加快 App 打包、组件 lint、组件发布等操作的目的。
33
39
 
34
- 使用本插件需要提供以下资源:
40
+ ### 1、环境搭建
35
41
 
36
- - 静态资源服务器(可参考 [binary-server](https://github.com/tripleCC/binary-server.git))
37
- - 源码私有源(保存组件源码版本 podspec)
38
- - 二进制私有源(保存组件二进制版本 podspec)
42
+ <br/>
39
43
 
40
- 在所有组件都依赖二进制版本的情况下,本插件支持切换指定组件的依赖版本。
44
+ [环境搭建详细教程](https://github.com/su350380433/cocoapods-imy-bin-demo)
41
45
 
42
- 推荐结合 GitLab CI 使用本插件,可以实现自动打包发布,并显著减少其 pipeline 耗时。关于 GitLab CI 的实践,可以参考 [火掌柜 iOS 团队 GitLab CI 集成实践](https://triplecc.github.io/2018/06/23/2018-06-23-ji-gitlabcide-ci-shi-jian/)。虽然后来对部分 stage 和脚本都进行了优化,但总体构建思路还是没变的。
46
+ 使用二进制时,本插件需要提供以下资源:
43
47
 
44
- ## 准备工作
48
+ - 静态资源服务器( [binary-server](https://github.com/su350380433/binary-server),附详细使用教程)
49
+ - 二进制私有源仓库(保存组件二进制版本 podspec)
45
50
 
46
- 安装 `cocoapods-bin`:
47
51
 
48
- $ gem install cocoapods-bin
49
52
 
50
- 初始化插件:
53
+ ### 2、初始化插件
51
54
 
52
- ```shell
53
- ➜ ~ pod bin init
55
+ ``` shell
56
+ xx:Demo slj$ pod bin init
57
+
58
+ ====== dev 环境 ========
54
59
 
55
60
  开始设置二进制化初始信息.
56
- 所有的信息都会保存在 /Users/songruiwang/.cocoapods/bin.yml 文件中.
61
+ 所有的信息都会保存在 /Users/slj/.cocoapods/bin_dev.yml 文件中.
62
+ %w[bin_dev.yml bin_debug_iphoneos.yml bin_release_iphoneos.yml]
57
63
  你可以在对应目录下手动添加编辑该文件. 文件包含的配置信息样式如下:
58
64
 
59
65
  ---
60
- code_repo_url: git@git.xxxxxx.net:ios/cocoapods-spec.git
61
- binary_repo_url: git@git.xxxxxx.net:ios/cocoapods-spec-binary.git
62
- binary_download_url: http://iosframeworkserver-shopkeeperclient.app.2dfire.com/download/%s/%s.zip
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
63
70
  download_file_type: zip
64
71
 
65
72
 
66
- 源码私有源 Git 地址
67
- 旧值:git@git.xxxxxx.net:ios/cocoapods-spec.git
68
- >
73
+ 编译环境
74
+ 可选值:[ dev / debug_iphoneos / release_iphoneos ]
75
+ 旧值:dev
69
76
  ```
70
77
 
71
- 按提示输入源码私有源、二进制私有源、二进制下载地址、下载文件类型后,插件就配置完成了。其中 `binary_download_url` 需要预留组件名称与组件版本占位符,插件内部会依次替换 `%s` 为相应组件的值。
78
+ 按提示输入`所属环境`、源码私有源、二进制私有源、二进制下载地址、下载文件类型后,插件就配置完成了。其中 `binary_download_url` 需要预留组件名称与组件版本占位符,插件内部会依次替换 `%s` 为相应组件的值。
72
79
 
73
80
  `cococapod-bin` 也支持从 url 下载配置文件,方便对多台机器进行配置:
74
81
 
75
82
  ```shell
76
- ➜ ~ pod bin init --bin-url=http://git.xxxxxx.net/qingmu/cocoapods-tdfire-binary-config/raw/master/bin.yml
83
+ ➜ ~ pod bin init --bin-url=https://github.com/su350380433/cocoapods-imy-bin-configs/raw/master/bin_dev.yml
77
84
  ```
78
85
 
79
86
  配置文件模版内容如下,根据不同团队的需求定制即可:
80
87
 
81
- ```yaml
88
+ ```shell
82
89
  ---
83
- code_repo_url: git@git.xxxxxx.net:ios/cocoapods-spec.git
84
- binary_repo_url: git@git.xxxxxx.net:ios/cocoapods-spec-binary.git
85
- binary_download_url: http://iosframeworkserver-shopkeeperclient.app.2dfire.com/download/%s/%s.zip
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
86
94
  download_file_type: zip
95
+
87
96
  ```
88
97
 
89
98
  配置时,不需要手动添加源码和二进制私有源的 repo,插件在找不到对应 repo 时会主动 clone。
90
99
 
91
- 插件配置完后,就可以部署静态资源服务器了。对于静态资源服务器,这里不做赘述,只提示一点:在生成二进制 podspec 时,插件会根据 `download_file_type` 设置 source 的 `:type` 字段。在下载 http/https 资源时,CocoaPods 会根据 `:type` 字段的类型采取相应的解压方式,如果设置错误就会抛错。这里提到了 **二进制 podspec 的自动生成**,后面会详细介绍。
100
+ 记得启动 `sudo mongod`服务,静态资源服务。
92
101
 
93
- 这里额外说下打包工具 [cocoapods-packager](https://github.com/CocoaPods/cocoapods-packager) 和 [Carthage](https://github.com/Carthage/Carthage/issues) ,前者可以通过 podspec 进行打包,只要保证 lint 通过了,就可以打成 `.framework`,很方便,但是作者几乎不维护了,后者需要结合组件工程。具体使用哪个可以结合自身团队,甚至可以自己写打包脚本,或者使用本插件的打包命令。
94
102
 
95
- ## 使用插件
103
+ <br/>
96
104
 
97
- 接入二进制版本后,常规的发布流程需要做如下变更:
105
+ ## 四、制作二进制组件
98
106
 
99
- ```shell
100
- # 1 打出二进制产物 && 提交产物至静态文件服务器
101
- pod bin archive YOUR_OPTIONS
102
- curl xxxxxxx
107
+ <br/>
103
108
 
104
- # 2.1 发布二进制 podspec
105
- pod bin repo push --binary YOUR_OPTIONS
109
+ [视频演示](https://github.com/MeetYouDevs/cocoapods-imy-bin/tree/master/%E6%BC%94%E7%A4%BA%E8%A7%86%E9%A2%91)
106
110
 
107
- # 2.2 发布源码 podspec
108
- pod bin repo push YOUR_OPTIONS
109
- ```
111
+ ### 1、制作命令
110
112
 
111
- 如果团队内部集成了 CI 平台,那么上面的每大步都可以对应一个 CI stage,源码和二进制版本可并行发布,对应一个 stage 中的两个 job。
113
+ 可以直接使用插件的 `pod bin auto`命令,在插件初始化配置完成后,目录下只要有包含podspec文件,根据podspec文件的version版本号会自动化执行build、组装二进制组件、制作二进制podspec、上传二进制文件、上传二进制podspec到私有源仓库。
112
114
 
113
- ### 基本信息
115
+ ```shell
116
+ pod bin auto
117
+ ```
114
118
 
115
- `cocoapods-bin` 命令行信息可以输入以下命令查看:
119
+ 带上`—all-make`参数会把当前组件所依赖的组件都自动化制作成二进制组件。
116
120
 
117
121
  ```shell
118
- ➜ ~ pod bin --help
119
- Usage:
122
+ pod bin local
123
+ ```
120
124
 
121
- $ pod bin [COMMAND]
125
+ pod bin local 是配合其他三方编译产物的命令,需要配置编译产物的目录。
122
126
 
123
- 组件二进制化插件。利用源码私有源与二进制私有源实现对组件依赖类型的切换。
127
+ `BinArchive.json`是制作二进制的一些配置项,放在项目跟目录下:
124
128
 
125
- Commands:
126
- + archive 将组件归档为静态 framework.
127
- + init 初始化插件.
128
- + lib 管理二进制 pod.
129
- + list 展示二进制 pods .
130
- > open 打开 workspace 工程.
131
- + repo 管理 spec 仓库.
132
- + search 查找二进制 spec.
133
- + spec 管理二进制 spec.
134
- + umbrella 生成伞头文件 .
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
+ }
135
147
  ```
136
148
 
137
- ### 构建二进制产物
138
149
 
139
- ```shell
140
- ➜ ~ pod bin archive --help
141
- Usage:
150
+ <br/>
142
151
 
143
- $ pod bin archive [NAME.podspec]
152
+ ### 2. 二进制Podspec
144
153
 
145
- 将组件归档为静态 framework,仅支持 iOS 平台 此静态 framework 不包含依赖组件的 symbol
154
+ 通过`pod bin auto`和`pod bin local`二进制Podspec 会自动生成、上传,无需关心。
146
155
 
147
- Options:
148
156
 
149
- --code-dependencies 使用源码依赖
150
- --allow-prerelease 允许使用 prerelease 的版本
151
- --use-modular-headers 使用 modular headers (modulemap)
152
- --no-clean 保留构建中间产物
153
- --no-zip 不压缩静态 framework 为 zip
154
- ...
155
- ```
157
+ <br/>
156
158
 
157
- `pod bin archive` 会根据 podspec 文件构建静态 framework ,此静态 framework 不会包含依赖组件的符号信息。命令内部利用 [cocoapods-generate](https://github.com/square/cocoapods-generate) 插件生成工程,并移植了 [cocoapods-packager](https://github.com/CocoaPods/cocoapods-packager) 插件的部分打包功能,以构建前者生成的工程,默认条件下,命令会生成一个 zip 压缩包。
159
+ ### 3、查看结果
158
160
 
159
- ### 二进制 podspec
161
+ 二进制存储服务:http://localhost:8080/frameworks/(默认本地8080端口)
160
162
 
161
- `cocoapods-bin` 针对一个组件,同时使用了两种 podspec,分别为源码 podspec 和二进制 podspec,这种方式在没有工具支撑的情况下,势必会增加开发者维护组件的工作量。做为开发者来说,我是不希望同时维护两套 podspec 的。为了解决这个问题, 插件提供了自动生成二进制 podspec 功能,开发者依旧只需要关心源码 podspec 即可。
163
+ 二进制私有源参考:https://github.com/su350380433/example_spec_bin_dev.git(自定义)
162
164
 
163
- 一般来说,在接入插件前,组件源码 podspec 是已经存在的,所以我们只需要向二进制私有源推送组件的二进制 podspec 即可。如果有条件的话,二进制和源码 podspec 的发布可以走 GitLab CI ,这也是我推荐的做法。
164
165
 
165
- 下面介绍下和二进制 podspec 相关的 `cocoapods-bin` 命令。
166
+ <br/>
166
167
 
167
- #### pod bin spec create
168
+ ### 4、使用二进制
168
169
 
169
- ```shell
170
- ➜ ~ pod bin spec create --help
171
- Usage:
170
+ <br/>
172
171
 
173
- $ pod bin spec create
172
+ [视频演示](https://github.com/MeetYouDevs/cocoapods-imy-bin/tree/master/%E6%BC%94%E7%A4%BA%E8%A7%86%E9%A2%91)
174
173
 
175
- 根据源码 podspec 文件,创建对应的二进制 podspec 文件.
174
+ 在Podfile文件中,加入这两行代码,对已经制作二进制的就会生效,自动转换二进制组件依赖。
176
175
 
177
- Options:
176
+ ``` ruby
177
+ plugin 'cocoapods-imy-bin'
178
+ use_binaries!
179
+ ```
178
180
 
179
- --platforms=ios 生成二进制 spec 支持的平台
180
- --template-podspec=A.binary-template.podspec 生成拥有 subspec 的二进制 spec 需要的模版
181
- podspec, 插件会更改 version 和 source
182
- --no-overwrite 不允许覆盖
183
- ...
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 => '../' #提交的时候往往要修改回来才提交,操作繁琐
184
202
  ```
203
+ 用法:
185
204
 
186
- `pod bin spec create` 会根据源码 podspec ,创建出二进制 podspec 文件。如果组件存在 subspec ,需要开发者提供 podspec 模版信息,以生成二进制 podspec。插件会根据源码 podspec 更改模版中的 version 字段,并且根据插件配置的 `binary_download_url` 生成 source 字段,最终生成二进制 podspec。
205
+ 在与Podfile同级目录下,新增一个`Podfile_local`文件,模板可到这里下载Podfile_local
187
206
 
188
- 以 A 组件举例,如果 A 的 podspec 如下:
189
207
 
190
208
  ```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
- }
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://覆盖、自定义/'
208
228
  end
209
229
  ```
210
230
 
211
- 那么生成的 `A.binary.podspec.json` 如下:
231
+ ```ruby
232
+ 以前的 pod update --no-repo-update 命令加个前缀 `bin` 变成
233
+ ```
212
234
 
213
- ```json
214
- {
215
- "name": "A",
216
- "version": "0.1.0",
217
- "summary": "business A short description of A.",
218
- "description": "TODO: Add long description of the pod here.",
219
- "homepage": "http://git.2dfire-inc.com/ios/A",
220
- "license": {
221
- "type": "MIT",
222
- "file": "LICENSE"
223
- },
224
- "authors": {
225
- "qingmu": "qingmu@2dfire.com"
226
- },
227
- "source": {
228
- "http": "http://iosframeworkserver-shopkeeperclient.app.2dfire.com/download/A/0.1.0.zip",
229
- "type": "zip"
230
- },
231
- "platforms": {
232
- "ios": "8.0"
233
- },
234
- "source_files": [
235
- "A.framework/Headers/*",
236
- "A.framework/Versions/A/Headers/*"
237
- ],
238
- "public_header_files": [
239
- "A.framework/Headers/*",
240
- "A.framework/Versions/A/Headers/*"
241
- ],
242
- "vendored_frameworks": "A.framework",
243
- "resources": [
244
- "A.framework/Resources/*.bundle",
245
- "A.framework/Versions/A/Resources/*.bundle"
246
- ]
247
- }
235
+ ```shell
236
+ pod bin update --no-repo-update
237
+ ```
238
+ or
239
+ ```shell
240
+ pod bin install
248
241
  ```
249
242
 
250
- 如果 A 拥有 subspec:
243
+ 支持 pod install/update 命令参数
251
244
 
252
- ```ruby
253
- Pod::Spec.new do |s|
254
- s.name = 'A'
255
- s.version = '0.1.0'
256
- s.summary = 'business A short description of A.'
257
- s.description = <<-DESC
258
- TODO: Add long description of the pod here.
259
- DESC
260
- s.homepage = 'http://git.2dfire-inc.com/ios/A'
261
- s.license = { :type => 'MIT', :file => 'LICENSE' }
262
- s.author = { 'qingmu' => 'qingmu@2dfire.com' }
263
- s.source = { :git => 'http://git.2dfire-inc.com/qiandaojiang/A.git', :tag => s.version.to_s }
264
- s.ios.deployment_target = '8.0'
265
- s.source_files = 'A/Classes/**/*'
266
- s.public_header_files = 'A/Classes/**/*.{h}'
267
- s.resource_bundles = {
268
- 'A' => ['A/Assets/*']
269
- }
270
- s.subspec 'B' do |ss|
271
- ss.dependency 'YYModel'
272
- ss.source_files = 'A/Classes/**/*'
273
- end
274
- end
245
+ 并将其加入 .gitignore ,再也不用担心我误提交或者冲突了,Podfile_local 中的配置选项优先级比 Podfile 高,支持和 Podfile 相同的配置语句,同时支持**pre_install** or **post_install**。
275
246
 
276
- ```
277
247
 
278
- 那么就需要开发者提供 `A.binary-template.podspec`(此模版中的写法假定组件的所有 subspec 都打进一个 `.framework` 里,如果 subpsec 都有属于自己的 `.framework` ,就可以采用其他写法。),**这里要注意源码版本 subspec 集合需要为二进制版本 subspec 集合的子集,否则会出现源码拉取失败或抛出 subspec 不存在错误的情况**:
248
+ 如果您不习惯Podfile_local的使用方式,可以把命令写在Podfile里面,pod时不需要加bin,依旧是 pod update/install。
279
249
 
280
- ```ruby
281
- Pod::Spec.new do |s|
282
- s.name = 'A'
283
- s.summary = 'business A short description of A.'
284
- s.description = <<-DESC
285
- TODO: Add long description of the pod here.
286
- DESC
287
- s.homepage = 'http://git.2dfire-inc.com/ios/A'
288
- s.license = { :type => 'MIT', :file => 'LICENSE' }
289
- s.author = { 'qingmu' => 'qingmu@2dfire.com' }
290
- s.ios.deployment_target = '8.0'
291
-
292
- s.subspec "Binary" do |ss|
293
- ss.vendored_frameworks = "#{s.name}.framework"
294
- ss.source_files = "#{s.name}.framework/Headers/*", "#{s.name}.framework/Versions/A/Headers/*"
295
- ss.public_header_files = "#{s.name}.framework/Headers/*", "#{s.name}.framework/Versions/A/Headers/*"
296
- # 结合实际打包后的资源产出文件类型编写
297
- ss.resources = "#{s.name}.framework/Resources/*.{bundle}", "#{s.name}.framework/Versions/A/Resources/*.{bundle}"
298
- ss.dependency 'YYModel'
299
- end
300
-
301
- s.subspec 'B' do |ss|
302
- ss.dependency "#{s.name}/Binary"
303
- end
304
- end
305
250
 
306
- ```
251
+ <br/>
307
252
 
308
- 最终生成的二进制 podspec 如下:
253
+ ### 2、二进制源码调试
309
254
 
310
- ```json
311
- {
312
- "name": "A",
313
- "summary": "business A short description of A.",
314
- "description": "TODO: Add long description of the pod here.",
315
- "homepage": "http://git.2dfire-inc.com/ios/A",
316
- "license": {
317
- "type": "MIT",
318
- "file": "LICENSE"
319
- },
320
- "authors": {
321
- "qingmu": "qingmu@2dfire.com"
322
- },
323
- "platforms": {
324
- "ios": "8.0"
325
- },
326
- "version": "0.1.0",
327
- "source": {
328
- "http": "http://iosframeworkserver-shopkeeperclient.app.2dfire.com/download/A/0.1.0.zip",
329
- "type": "zip"
330
- },
331
- "subspecs": [
332
- {
333
- "name": "Binary",
334
- "vendored_frameworks": "A.framework",
335
- "source_files": [
336
- "A.framework/Headers/*",
337
- "A.framework/Versions/A/Headers/*"
338
- ],
339
- "public_header_files": [
340
- "A.framework/Headers/*",
341
- "A.framework/Versions/A/Headers/*"
342
- ],
343
- "resources": [
344
- "A.framework/Resources/*.{bundle}",
345
- "A.framework/Versions/A/Resources/*.{bundle}"
346
- ],
347
- "dependencies": {
348
- "YYModel": [
349
-
350
- ]
351
- }
352
- },
353
- {
354
- "name": "B",
355
- "dependencies": {
356
- "A/Binary": [
357
-
358
- ]
359
- }
360
- }
361
- ]
362
- }
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
363
263
  ```
364
264
 
365
- #### pod bin spec lint
265
+ `YYModel`为需要源码调试的组件库名称。成功之后像平时一样单步调试,控制台打印变量。让我们同时拥有使用二进制的便利和源码调试的能力。
366
266
 
367
- ```shell
368
- ➜ ~ pod bin spec lint --help
267
+ ``` shell
268
+ $ pod bin code --help [11:37:50]
369
269
  Usage:
370
270
 
371
- $ pod bin spec lint [NAME.podspec|DIRECTORY|http://PATH/NAME.podspec ...]
271
+ $ pod bin code [NAME]
372
272
 
373
- spec lint 二进制组件 / 源码组件
273
+ 通过将二进制对应源码放置在临时目录中,让二进制出现断点时可以跳到对应的源码,方便调试。 在不删除二进制的情况下为某个组件添加源码调试能力,多个组件名称用空格分隔
374
274
 
375
275
  Options:
376
276
 
377
- --binary lint 组件的二进制版本
378
- --template-podspec=A.binary-template.podspec 生成拥有 subspec 的二进制 spec 需要的模版
379
- podspec, 插件会更改 version 和 source
380
- --reserve-created-spec 保留生成的二进制 spec 文件
381
- --code-dependencies 使用源码依赖进行 lint
382
- --loose-options 添加宽松的 options, 包括 --use-libraries
383
- (可能会造成 entry point (start)
384
- undefined)
385
- ...
277
+ --all-clean 删除所有已经下载的源码
278
+ --clean 删除所有指定下载的源码
279
+ --list 展示所有一级下载的源码以及其大小
280
+ --source 源码路径,本地路径,会去自动链接本地源码
386
281
  ```
387
282
 
388
- `pod bin spec lint` 默认使用二进制依赖进行 lint,在添加 `--binary` 会去 lint 当前组件的二进制 podspec(动态生成)。在添加 `--code-dependencies` 将会使用源码依赖进行 lint ,个人推荐使用二进制依赖 lint,可以极大地减少编译时间。
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)
389
284
 
390
- #### pod bin repo push
285
+
286
+ <br/>
287
+
288
+ ### 3、快捷键命令
289
+
290
+ <br/>
291
+
292
+ 在任意的终端执行命令,都能执行特定目录下特定命令
293
+
294
+ 使用命令:
391
295
 
392
296
  ```shell
297
+ pod bin imy
298
+ ```
393
299
 
394
- ➜ ~ pod bin repo push --help
395
- Usage:
300
+ or
396
301
 
397
- $ pod bin repo push [NAME.podspec]
302
+ ``` shell
303
+ pod bin imy 2 #2 是自定义的快捷键
304
+ ```
398
305
 
399
- 发布二进制组件 / 源码组件
306
+ 使用场景:
400
307
 
401
- Options:
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
+ 你可以在对应目录下手动添加编辑该文件. 文件包含的配置信息样式如下:
402
319
 
403
- --binary 发布组件的二进制版本
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, 包括
409
- --use-libraries (可能会造成 entry
410
- point (start) undefined)
411
- ...
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
412
329
  ```
413
330
 
414
- `pod bin repo push` 用来发布组件,其余特性和 `pod bin spec lint` 一致。
415
331
 
416
- ### Podfile DSL
332
+ <br/>
333
+
334
+ ## 六、 DSL参数解释
417
335
 
418
- 首先,开发者需要在 Podfile 中需要使用 `plugin 'cocoapods-bin'` 语句引入插件 :
336
+
337
+
338
+ 首先,开发者需要在 Podfile 中需要使用 `plugin 'cocoapods-imy-bin'` 语句引入插件
419
339
 
420
340
  ```ruby
421
- plugin 'cocoapods-bin'
341
+ plugin 'cocoapods-imy-bin'
422
342
  ```
423
343
 
424
344
  顺带可以删除 Podfile 中的 source ,因为插件内部会自动帮你添加两个私有源。
425
345
 
426
346
  `cocoapods-bin `插件提供二进制相关的配置语句有 `use_binaries!`、`use_binaries_with_spec_selector!` 以及 `set_use_source_pods`,下面会分别介绍。
427
347
 
428
- #### use_binaries!
348
+ ##### use_binaries!
429
349
 
430
350
  全部组件使用二进制版本。
431
351
 
@@ -435,48 +355,7 @@ plugin 'cocoapods-bin'
435
355
  use_binaries! (ENV['DEBUG'].nil? || ENV['DEBUG'] == 'true')
436
356
  ```
437
357
 
438
- 当组件没有二进制版本时,插件会强制工程依赖该组件的源码版本。开发者可以通过执行 `pod install--verbose` option ,在分析依赖步骤查看哪些组件没有二进制版本:
439
-
440
- ```shell
441
- ...
442
- Resolving dependencies of `Podfile`
443
- 【AMapFrameworks | 0.0.4】组件无对应二进制版本 , 将采用源码依赖.
444
- 【ActivityForRestApp | 0.2.1】组件无对应二进制版本 , 将采用源码依赖.
445
- 【AssemblyComponent | 0.5.9】组件无对应二进制版本 , 将采用源码依赖.
446
- 【Bugly | 2.4.6】组件无对应二进制版本 , 将采用源码依赖.
447
- 【Celebi | 0.6.4】组件无对应二进制版本 , 将采用源码依赖.
448
- 【CocoaAsyncSocket/RunLoop | 7.4.3】组件无对应二进制版本 , 将采用源码依赖.
449
- 【CocoaLumberjack | 3.4.1】组件无对应二进制版本 , 将采用源码依赖.
450
- 【CocoaLumberjack/Default | 3.4.1】组件无对应二进制版本 , 将采用源码依赖.
451
- 【CocoaLumberjack/Extensions | 3.4.1】组件无对应二进制版本 , 将采用源码依赖.
452
- 【CodePush | 0.3.1】组件无对应二进制版本 , 将采用源码依赖.
453
- 【CodePush/Core | 0.3.1】组件无对应二进制版本 , 将采用源码依赖.
454
- 【CodePush/SSZipArchive | 0.3.1】组件无对应二进制版本 , 将采用源码依赖.
455
- 【ESExchangeSkin | 0.3.2】组件无对应二进制版本 , 将采用源码依赖.
456
- ...
457
- ```
458
-
459
- 也可以通过 Podfile.lock 中的 `SPEC REPOS` 字段,查看哪些组件采用了源码版本,哪些采用了二进制版本:
460
-
461
- ```yaml
462
- ...
463
- SPEC REPOS:
464
- "git@git.xxxxxx.net:ios/cocoapods-spec-binary.git":
465
- - AFNetworking
466
- - Aspects
467
- - CocoaSecurity
468
- - DACircularProgress
469
- ...
470
- "git@git.xxxxxx.net:ios/cocoapods-spec.git":
471
- - ActivityForRestApp
472
- - AMapFrameworks
473
- - AssemblyComponent
474
- ...
475
- ...
476
- ```
477
-
478
-
479
- #### set_use_source_pods
358
+ ##### set_use_source_pods
480
359
 
481
360
  设置使用源码版本的组件。
482
361
 
@@ -488,7 +367,7 @@ set_use_source_pods ['YYModel']
488
367
 
489
368
  如果 CocoaPods 版本为 1.5.3 ,终端会输出以下内容,表示 YYModel 的参照源从二进制私有源切换到了源码私有源:
490
369
 
491
- ```shell
370
+ ```ruby
492
371
  Analyzing dependencies
493
372
  Fetching podspec for `A` from `../`
494
373
  Downloading dependencies
@@ -500,7 +379,7 @@ Sending stats
500
379
  Pod installation complete! There is 1 dependency from the Podfile and 2 total pods installed.
501
380
  ```
502
381
 
503
- #### use_binaries_with_spec_selector!
382
+ ##### use_binaries_with_spec_selector!
504
383
 
505
384
  过滤出需要使用二进制版本组件。
506
385
 
@@ -531,7 +410,29 @@ use_binaries_with_spec_selector! do |spec|
531
410
  end
532
411
  ```
533
412
 
534
- #### 其他设置
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
+ ##### 其他设置
535
436
 
536
437
  插件默认开启多线程下载组件资源,如果要禁用这个功能,Podfile 添加以下代码即可:
537
438
 
@@ -539,3 +440,15 @@ end
539
440
  install! 'cocoapods', { install_with_multi_threads: false }
540
441
  ```
541
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。