步骤归纳:
1 创建远程索引库
2 将远程索引库添加到本地
3 创建本地私有库,完成测试
4 修改Spec文件
5 提交私有库代码并增加tag
6 提交spec至私有索引库
7 测试
第一步 第二步请自行百度 这里不赘述了
3:创建本地私有库 ( 此处以 ZYExtension为例)
cd 到指定目录下,然后 pod lib create ZYExtension
![](https://img.haomeiwen.com/i581852/e2c07569736eace8.png)
以上配置针对个人需要进行配置,此处因为我本人是希望创建一个swift的远程私有库,所以此处语言我选择了Swift。配置完成之后,会自动打开一个响应的Example项目。该项目如下:
![](https://img.haomeiwen.com/i581852/01cf14dd343725d7.png)
将需要放到该私有库的文件替换Classes文件夹中的Replace.swift
cd 到Example目录下 执行pod install命令,在Example中进行测试,确保组件可用。
以下是Spec文件简单介绍 : 由于项目需要支持到swift 4.0 所以需要指定版本
![](https://img.haomeiwen.com/i581852/5af3a0fb0074e1ca.png)
![](https://img.haomeiwen.com/i581852/f93348914546a575.png)
s.source 这个地方要填写 远程仓库地址 而不是本地私有库 (默认生成的是本地私有库地址)
提交私有库代码并增加tag
将代码提交到组件远程仓库,常用的git命令,git工具就不说了
git add .
git commit -m '第一次提交'
git add origin https://github.com/PZYan/TestCourse.git
遇到错误 解决如下
![](https://img.haomeiwen.com/i581852/01a1badfa4e4464b.png)
! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'https://github.com/PZYan/TestCourse.git'
![](https://img.haomeiwen.com/i581852/af2c9f46ba81bf02.png)
提交私有库代码并增加tag
指定版本 echo "4.0" > .swift-version
如果有私有库添加进去私有库 sources='https://github.com/CocoaPods/Specs.git,私有库'
![](https://img.haomeiwen.com/i581852/41411690121eb544.png)
[!] ZYExtension did not pass validation, due to 11 warnings (but you can use `--allow-warnings` to ignore them).You can use the `--no-clean` option to inspect any issue.
解决方案:pod lib lint --sources='https://github.com/CocoaPods/Specs.git,http://123.57.226.216/app/YBSSpec.git' --allow-warnings
注: 'http://123.57.226.216/app/YBSSpec.git' 是公司自己搭建的GitLib上的组件库地址 不要搞混淆了,
![](https://img.haomeiwen.com/i581852/e18096bc85622890.png)
成功如下:
![](https://img.haomeiwen.com/i581852/05bb618a1e14eb6a.png)
错误一
-> ZYExtension (0.1.0)
- WARN | description: The description is shorter than the summary.
- WARN | url: The URL (https://github.com/PZYan/ZYExtension) is not reachable.
- ERROR | [iOS] unknown: Encountered an unknown error ([!] /usr/bin/git clone https://github.com/PZYan/TestCourse.git /var/folders/6j/dk00xh8j7kj9rvs4mxvp_xqc0000gn/T/d20200530-16312-oxjk8m --template= --single-branch --depth 1 --branch 0.1.0
Cloning into '/var/folders/6j/dk00xh8j7kj9rvs4mxvp_xqc0000gn/T/d20200530-16312-oxjk8m'...
error: RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
fatal: the remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
错误二
->ZYExtension (0.1.0)
- WARN | url: The URL (https://github.com/PZYan/ZYExtension) is not reachable.
- ERROR | [iOS] unknown: Encountered an unknown error (Pod::DSLError) during validation.
解决如下
创建个子分子 然后切换到master 再删除子分子 再重新pod spec lint 就可以成功了
git branch -t deve
git chechout master
git branch --delete deve
git add .
git commit -m '上传修改'
git push origin master
git tag '0.1.1'
git push --tags
pod spec lint --private --sources='https://github.com/CocoaPods/Specs.git,http://123.57.226.216/app/YBSSpec.git' --allow-warnings
![](https://img.haomeiwen.com/i581852/8fee0b62e2a104a5.png)
最后
pod repo push TestCourse ZYExtension.podspec --allow-warnings
![](https://img.haomeiwen.com/i581852/fc98133e72585295.png)
恭喜你 成功了啦!!!!
参考资料如下:
网友评论