创建CocoaPods公有仓库

pod项目中常见的,创建也很简单,就直接按1,2,3步骤操作就行~

1.有2种方式创建

a方式: 在github上创建好空项目(包含license ,MIT,ReadMe)创建好直接clone到本地,

然后cd到项目执行下面命令会在项目中生成 YourProject.podspec文件

b方式:用pod创建

What language do you want to use?? [ Swift / ObjC ]
ObjC
Would you like to include a demo application with your library? [ Yes / No ]
Yes
Which testing frameworks will you use? [ Specta / Kiwi / None ]
Kiwi
Would you like to do view based testing? [ Yes / No ]
No
What is your class prefix?

然后进入项目添加github上的地址


2.然后编辑


3.然后验证

如果成功会是下面

这里很可能会出问题,主要检查出错的log和podspec


4.把项目push到远程和打tag


5.发布.podspec

把上面生成的YourProject.podspec发布

如果你没有注册过,会出[!] You need to register a session first. 然后执行下面6去注册


6.注册pod  trunk

然后去项目验证下会看到下面


7.查看trunk信息

– Name: rongtian
– Email: 121071838@qq.com
– Since: November 17th, 03:48
– Pods: None
– Sessions:
– November 17th, 03:48 – March 25th, 2018 03:50. IP: 111.202.106.229 Description:
DumbPatch

然后再执行5.发布.podspec

YourProject.podspec 发布到公有的speecs上包括 更新本地 pods 库 ~/.cocoaPods.repo/master

  • 验证.podspec格式是否正确
  • .podspec 文件转 JSON
  • master 仓库 进行合并、提交.master仓库地址

如果成功会有下面类似log

——————————————————————————–
🎉 Congrats

🚀 DumbPatch (0.0.1) successfully published
📅 November 17th, 07:19
🌎 https://cocoapods.org/pods/YourProject
👍 Tell your friends!
——————————————————————————–


8. 然后pod search YourProject

可以直接在cocoapods官网直接查询

然后本地执行

然后直接项目使用 pod ‘YourProject’, ‘~>0.1.0’

⚠️[!] Unable to find a pod with name, author, summary, or description matching DumbPatch如果搜不到试试下面,或者在cocoapods官网直接查询


9.更新

  • YourProject.podspec版本号,如果结构变了里面也相应修改
  • 打tag(这个最好和podspec版本号一致)
  • pod trunk push YourProject.podspec

附加:

1.查看本地repos结构

2.更新本地pod库(不要搞错了)

  • pod install 本不会更新,还是用本地库里的版本
  • pod update 会fetch .cocoapods/repos/master

https://github.com/CocoaPods/Specs

发表回复

电子邮件地址不会被公开。 必填项已用*标注