读https://www.jianshu.com/p/006d6ab89c3c后小结
1)CocoaPods公有公共仓库
打开“访达” command + shift + g ~/.cocoapods/repos

上面JZRepo、JZTRepo是自建的私有索引库 master是cocoaPods的公共git仓库(Specs是索引库)
2)在码云上新建私有仓库和私有索引库(是否开源选私有)
如何新建就不赘述了,关键是创建好之后用作存储代码的仓库里面的3个文件最好先删掉(因为后面pull合并时很容易有冲突)

我这里创建的是

3)创建私有索引库
终端输入 pod repo add JZTRepo https://gitee.com/JZ_Team/JZTRepo.git
就会在~/.cocoapods/repos目录下看到JZTRepo目录
4)创建测试工程
终端输入 cd ~/Desktop/ 进入桌面
输入pod lib create JZTImageView(工程名) 会跳出下列提示,按实际情况选择答案

成功后会在桌面创建一个JZTImageView工程

点击打开,然后新建一个分类文件,将新建的.h和.m一起拖入下面的Classes文件夹下

在Xcode打开的JZTImageView工程下点击.podspec文件进行修改

5)提交工程到码云
终端cd /Users/dz/Desktop/JZTImageView 进入工程文件夹
cd Example/ 进入Example文件夹
pod install 安装

git remote -v 查询添加的远程库
git remote add origin https://gitee.com/JZ_Team/JZTImageView.git 添加远程库
再次查询会出现

git add .
git commit -m "first"
git pull origin master --allow-unrelated-histories
git push origin master
git status 查看推送是否成功
git tag -l 查看标签
git tag -a 0.1.0 -m "0.1.0版本" 添加本地标签 (版本号要与.podspec文件里面一致)
git push origin master --tags 推送到远程仓库 推送后可以刷新码云代码仓库查看标签是否改变 (我修改工程前后推送了2次版本)

pod lib lint --allow-warnings 本地编译
pod spec lint --allow-warnings 远程编译 成功如下路

pod repo push JZTRepo JZTImageView.podspec --allow-warnings 推送索引 成功后如下图


输入pod search JZTImageView

6)验证
桌面上用Xcode新建工程JZTest
终端cd /Users/dz/Desktop/JZTest
pod init
vim Podfile 打开后如下图

pod install


网友评论