参考:https://www.jianshu.com/p/9992feb8b00b
创建cocopod的步骤
1.创建一个spec Repo的私有远程仓库 和 一个存放pod所需的项目工程文件的远程仓库
2.创建spec Repo
3.创建pod的所需的项目工程文件,并上传到远程私有仓库
4.向私有的spec Repo远程仓库中提交podspec
5.使用自己创建的私有pod库
6.更新pod库
1.创建一个远程git

2.创建spec repo
前往文件夹 ~/.cocoapods/repos
打开终端,在终端切换到当前目录下,然后进行pod repo add操作
在终端输入:
pod repo add DZUIKitSpechttps://github.com/gitchenyuke/DZUIKit.git(之前创建的远程仓库地址)

3.1创建本地pod的所需的项目工程文件
cd 切换到一个目录下(我是在桌面上的MyPod目录下),然后执行pod lib create DZUIKit如图:

打开创建好的工程文件Example里Podfile文件删掉报错的pod

把要上传的代码放入创建工程的Classes里 并删除ReplaceMe文件

然后cd 到Example 目录下
Pod install
然后打开工程修改podspec

修改完成后,cd 到DZUIKit目录下,然后验证podspec文件
pod lib lint DZUIKit.podspec //进行本地验证文件有效性。
本地验证成功如下

3.2本地项目文件上传到远程库中
使用git remote add origin 远程仓库地址 // 将本地项目与远程仓库关联
然后git push origin master 提交
如果报错如下

输入命令
git add .
git commit -m "提交描述"
git push origin master 提交
如果还报git pull的错的话
先执行git pull origin master --allow-unrelated-histories
接着再执行
git push origin master
提交成功


远程仓库提交的信息
cd到DZUIKit目录下
执行pod spec lint DZUIKit.podspec 进行本地和远程验证文件有效性
报错如下

显示我们没有远程仓库打标签,这里需要重点注意的是,我们给打的标签值要与podspec文件中的版本号一致

打标签的步骤图

Release 可以看到

再次执行验证 pod spec lint DZUIKit.podspec
验证成功如下

4.向私有的spec Repo远程仓库中提交podspec
执行 pod repo push DZUIKitSpec DZUIKit.podspec 命令把私有库添加到私有repo中
注意的是:仍然在本项目的目录路径下进行操作:
成功后前往文件夹 ~/.cocoapods/repos去查看XHMSpec目录下的文件如下

pod repo // 查看第三方框架仓库源

5.注册上传到CocoaPods所用的账号
5.1pod trunk register 邮箱 '用户名' –description='描述'
5.2然后在邮箱里打开收到的地址打开验证
5.3验证后查看pod trunk me
5.4上传 pod trunk push 耐心等待
5.5上传成功

5.6搜索 pod search DZUIKit
如果搜索不出来前往文件夹~/Library/Caches/CocoaPods/

如果还报一下错误

~/.cocoapods/repos 前往文件夹把DZUIKit其余的删掉只留如下

然后在搜索
搜索成功

6.更新库内容并重新提交
6.1 在DZUIKit内修改你要更新的内容 或文件

注意:记得修改podspec文件里的版本

然后cd到Example目录下pod install
然后在cd到DZUIKit工程目录下
执行
git add .
git commit -m "更新内容"
git push origin master
如果失败 再
git add .
git commit -m "更新内容"
git push origin master
一次
将本地库更新到远程库


创建新的tag
git tag '0.1.1' (需要更podspec里的版本一样)
git push --tags


都修改好之后重新提交
pod trunk push
更新成功

搜索pod search DZUIKit

网友评论