美文网首页
cocoapods私有库:pod subspec 子模块

cocoapods私有库:pod subspec 子模块

作者: pigLily | 来源:发表于2021-04-30 15:53 被阅读0次

cocoapods私有库创建子模块的形式:

image.png
1.修改项目文件夹结构
image.png
2.提交到远程仓库
git add .
git commit -m "文件夹结构调整"
git push -u origin master
//tag 值增加
git tag 0.5.0
//推送tag到服务器上
git push --tags
3.修改.podspec文件
image.png
4.终端cd到本地仓库TestLib文件加下, 调用pod lib lint --allow-warnings和 pod spec lint -allow-warnings检测TestLib.podspec文件
image.png
5.终端cd到TestLib文件夹, 执行命令 pod repo push 私有索引库名 podspec文件名, 将podspec添加到本地私有索引库, 然后自动push到远程索引库:pod repo push TestSpec TestLib.podspec --allow-warnings
在校验的时候遇到了一些坑,报错:- ERROR | [iOS] unknown: Encountered an unknown error (Pod::DSLError) during validation.
image.png
经过一系列搜索发现是tag问题,然后重新打tag,并push到远程仓库。再联网校验时遇到这种错误:
ERROR | [iOS] unknown: Encountered an unknown error (Unable to find a specification for SDWebImage depended upon by TestLib/LoadImage
image.png
这是因为依赖的三方库是官方pod库,添加上源:
pod spec lint TestLib.podspec --allow-warnings --sources='https://github.com/CocoaPods/Specs.git'
![image.png](https://img.haomeiwen.com/i6351042/cf44996f49ed5a04.png?imageMogr2
/auto-orient/strip%7CimageView2/2/w/1240)
6.提交本地podspec到Specs仓库:
pod repo push TestSpec TestLib.podspec --allow-warnings --sources=https://e.coding.net/wojia/testdemo/TestSpec.git,https://github.com/CocoaPods/Specs.git
image.png
7.项目中使用TestLib库
有三种用法
pod 'TestLib' 引入pod库中所有模块
pod 'TestLib/Capture' 只引入GTimer模块
pod 'TestLib', :subspecs => ['Capture', 'LoadImage','User']

ps:如果子模块中依赖第三方,需要添加dependency

image.png
并且在执行pod spec lint 会报错,上面也提到了
image.png
在此也强调下,因为依赖的三方库是官方pod库中的,添加上源:pod spec lint TestLib.podspec --allow-warnings --sources='https://github.com/CocoaPods/Specs.git'

相关文章

网友评论

      本文标题:cocoapods私有库:pod subspec 子模块

      本文链接:https://www.haomeiwen.com/subject/qkbnrltx.html