iOS Pod私有库创建步骤

2019-06-06  本文已影响0人  吕建雄

一:创建pod私有库步骤:

1:先在Git上创建私有库

页面

会得到一个私有仓库地址:htts://github.com/Totti/xxx.git (xxx表示项目名称)

二:创建本地项目:

1:进入终端,cd到目标目录下

pod lib create xxx

//将会经过如下一系列询问

步骤

2:以上步骤完成后,将会自动打开XCode项目,修改xxx.podspec

podSpec文件

3:cd Example/ 

4:pod update --no-repo-update

update

5:pod lib lint

pod lib lint结果

6: git remote add origin htts://github.com/Totti/xxx.git

7: git add .

8: git commit -a -m "创建Monitor项目"

9: git push -u origin HEAD

至此就将创建的私有库上传到gitlab上;

10: 项目发布

git tag 0.1.0

git push origin 0.1.0

要想被使用,还需向私有 CocoaPods 远程索引库提交 podspec 描述文件;

二:向私有 CocoaPods 远程索引库提交 podspec 描述文件

1:添加远程索引库

pod repo add PrivateSpecs https://github.com/TottiLv/PrivateSpecs.git

注意:如果https://github.com/TottiLv/PrivateSpecs.git不存在,先在git上创建一个PrivateSpecs库(名字可自己确定)

2: 验证spec是否正确

pod spec lint--allow-warnings

3: 向PrivateSpecs提交podspec

pod repo push  PrivateSpecs  xxx.podspec --allow-warnings

(注意:xxx.podspec路径需注意,必须是.podspec的路径)

完成之后这个组件库就添加到我们的私有Spec Repo中了,可以进入到~./cocoapods/repos/xxx目录下查看

至此,通过pod search xxx就能搜索到

后两个命令执行截图

三:如果搜索不到报错

[!] Unable to find a pod with name, author, summary, or description matching `xxx`

需删除本地cache,命令如下:

rm ~/Library/Caches/CocoaPods/search_index.json 

再执行 pod search xxx 则能搜索到

上一篇下一篇

猜你喜欢

热点阅读