上传代码到Cocoapods
2017-05-27 本文已影响0人
crossyf
近来无事,研究了一下如何将自己的代码提交到cocoapods,以便使用的时候直接pod install。废话不多说,直接上过程。
第一步,当然要写好你准备上传的代码,然后提交到github上,具体与git相关操作这里不多说了。有一点,要给你的代码打上tag值,也就是github上对应的releases,

相关命令行:
git tag -a '0.0.1' -m "注释"
git push --tags
然后在代码目录下利用终端创建podspec文件

终端命令是
pod spec create yourLibName
,创建好spec文件后用xocde打开,修改里面的信息。

这里面s.version 是你上传到github的releases 的tag值,s.summary是简介

s.homePage对应的是你gihub仓库主页的地址
s.license为MIT(删除括号里的example)
s.source 对应的是github上该仓库的地址


最后就是修改s.sourse_files,sourse_files就是你要上传的代码块的文件地址,
Classes代表文件名,*代表相对路径,代表文件夹名称,{h,m}表示文件夹里面所有的.h和.m文件

修改好spce文件后,保存并退出,然后终端执行命令
pod trunk register youremail 'yourname' --verbose
邮箱会收到一条邮件,复制邮件里面的地址在浏览器内打开即可注册成功。
执行命令
yangfan$ pod trunk push CocoapodsTest.podspec
等待一段时间后便提交完成,提交完成后会有一短时间的审核期,审核期过后你就可以通过命令
pod search
查找你提交的库了。