-Updatte 20211218: 1.对于多层级subspec
可以参考QMUIKit; 2.若是测试验证时pod install
拉下了整个项目仓库, 确认下Podfile文件source指定的路径是否是spec库
的git地址
-Updatte 20210602: 更多CocoaPods实现细节, 原理, 源码实践参考CocoaPods历险记
准备资料
关于pod repo
1 | ➜ ytmqtt (master) ✔ pod repo --help |
补充
1.私有库必须使用$pod repo push REPO [NAME.podspec]
; 公开库发布使用$pod trunk push [NAME.podspec]
发布到Trunk. 官方文档在Getting setup with Trunk有说明.
2.$pod repo
同$pod repo list
1 | ➜ devhhb (master) ✗ pod repo |
3.若使私有库能如公开库一样执行$pod search [pod name]
,$pod install
等. 那么必须就得自行创建一个本地的repo文件夹充当spec的版本索引目录表. $pod repo add giteeSpec git@gitee.com:devhhb/specs.git
4.一贯做法, 本地私有库spec文件会统一管理, 可以参考官方例子artsy-specs, 阿里云aliyun 或者已生成的私有Specs.
后续执行指令$pod repo push REPO [NAME.podspec]
发布私有库后, 生成的文件目录大致如下
1 | ➜ giteeSpec (master) ✔ tree |
关于podfile解读
1 | 注意pod引入的几种方式, |
所以假定私有库有两个版本 0.0.1和0.0.2; 那么版本更新时, pod ‘xxx’, ‘~> 0.0.1’, 引入的仍然是0.0.2; 因为只要< 0.1.0
就满足了
1 | 官方文档描述如下 |
补充
1.本地pod引入方式pod 'Alamofire', :path => '~/Documents/Alamofire'
2.Podfile的根目录中有一个隐式抽象目标,因此项目有多个target时可以省略外层抽象target
简述步骤
创建私有repo
1.创建私有repo管理仓库specs, 并添加到本地. 可以是$pod repo add giteeSpec git@gitee.com:devhhb/specs.git
2.执行$pod repo
查看, 并cd
到目标私有repo文件夹, $pod lint .
加以校验
制作私有Pod
制作私有Pod过程前面基本同制作公开Pods流程, 仅发布时需要注意.
必须使用$pod repo push REPO [NAME.podspec]
必须使用$pod repo push REPO [NAME.podspec]
必须使用$pod repo push REPO [NAME.podspec]
补充
1.同样的需要本地校验spec文件. $pod lib lint
或者pod spec lint [NAME.podspec]
.
2.注意执行发布指令$ pod repo push REPO_NAME SPEC_NAME.podspec
时, 指定的podspec文件所处路径和前面创建私有repo文件夹名称. 如$pod repo push artsy-specs ~/Desktop/Artsy+OSSUIFonts.podspec
$pod repo push smarthome-specs /Users/design/Documents/code/ytsmartkit/YTSmartKit.podspec
测试Pods
使用私有库时需要在Podfile文件中顶部先引入私有库源source '[Private Pods URL]'
例如.
要使用pod 'Artsy+OSSUIFonts'
那么提前引入source 'https://github.com/artsy/Specs.git'
要使用pod 'IotLinkKit'
那么提前引入source 'https://github.com/aliyun/aliyun-specs.git'
要使用pod 'YTMqtt', '0.0.1'
那么提前引入source 'git@gitee.com:devhhb/specs.git'
相关引用
- 本文作者: 醉疏狂
- 本文链接: https://hubin97.github.io/2021/04/12/制作私有Pods/
- 版权声明: 本博客所有文章除特别声明外,均采用 MIT 许可协议。转载请注明出处!