创建私有pod库:
创建公有Pod库或者私有Pod库, 实际上原理是一样的, 都是基于git服务和repo协议, 不一样的是, 两者的版本索引查询方式不一样, 公有库的podspec由CocoaPods/Specs管理, 而内部私有使用的pod库需要自己建立一个仓库来管理podspec.
1 2 3
|
pod lib create [repo-name]
|
回车之后,终端会询问你几个哲学的问题
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| # 选择编程语言 What language do you want to use?? [ Swift / ObjC ] > Objc
# 在你的项目中是否创建一个demo工程,为了方便测试,我选择了Yes Would you like to include a demo application with your library? [ Yes / No ] > Yes
# 测试框架选择哪一个 Which testing frameworks will you use? [ Specta / Kiwi / None ] > None
# 要不要做视图测试 Would you like to do view based testing? [ Yes / No ] > Yes
# 类前缀名 What is your class prefix? > GJ
|
pod项目安装
1 2
| pod install --no-repo-update
|
编辑CocoaPods的配置文件(后缀名为podspec)

pod项目更新
1 2
| pod update --no-repo-update
|
验证pod配置文件
发布项目
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| # 添加远程地址,即上面创建码云项目的地址 BetterdeMacBook-Pro:PrivateHelloWorld better$ git remote add origin https: # 添加文件 BetterdeMacBook-Pro:PrivateHelloWorld better$ git add . # 提交本地,并写描述 BetterdeMacBook-Pro:PrivateHelloWorld better$ git commit -a -m "第一次提交 版本为0.0.1" # --allow-unrelated-histories # git pull origin maste会失败 ,提示:fatal: refusing to merge unrelated histories # 原因是远程仓库origin上的分支master和本地分支master被Git认为是不同的仓库,所以不能直接合并,需要添加 --allow-unrelated-histories
BetterdeMacBook-Pro:PrivateHelloWorld better$ git pull origin master --allow-unrelated-histories # 推送到码云的PrintHelloWolrd项目的master分支上 BetterdeMacBook-Pro:PrivateHelloWorld better$ git push origin master # 提交版本号 BetterdeMacBook-Pro:PrivateHelloWorld better$ git tag 0.0.1 # push到远程分支 BetterdeMacBook-Pro:PrivateHelloWorld better$ git push origin 0.0.1
|
创建并发布Sepc管理库
1 2 3 4 5 6
| pod repo add [repo-name] [git-url]
pod repo push [repo-name] [name.podspec]
pod repo remove [repo-name]
|
使用Cocoapods私有库
- 指定其他工程的
Podfile
文件中source
字段为私有仓库repo
仓库地址1
| pod 'repo-name', :source=>'cocoapods-repo-url'
|