如何创建一个公有 Pod 库 #29
onnttf
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
注意: 文中使用
{}
包裹的位置都需要根据您自身情况进行设置。如果您已经是
COCOAPODS
用户,请直接跳到第二节。注册
COCOAPODS
用户注册 Session
去邮箱点击验证链接
此时您的邮箱中应该有一封主题是 [CocoaPods] Confirm your session. 的邮件,点击邮件中的链接进行验证。
验证是否注册成功
下面内容,表示您已经注册成功。
创建公有 Pod 库
创建一个
Git
仓库创建过程请自行百度,谢谢!!!如果是在搜不到,那就私信我吧!😓
假设我们已经成功创建了一个仓库,关键信息如下:
HTTPS
地址,别问为什么,因为CocoaPods
要求:https://github.com/{YOURGITHUBNAME}/{YOURPODNAME}.git创建 Pod 库
在终端中执行:
pod lib create {YOURPODNAME}
,接下来按照提示,根据自己的情况进行选择就可以了。编辑 YOURPODNAME.podspec
必须要修改的:
s.summary
: pod 摘要s.description
: pod 描述s.homepage
: pod 在 github 中的地址s.author
: 作者姓名及邮箱s.source
: pod 的 git 地址其余的根据您的实际情况进行修改,每个字段的描述,下篇文章中会详细介绍!
验证 YOURPODNAME.podspec
虽然上面还有两个
WARN
,但是已经符合官方的标准了,可以进行提交操作了。但是!如果您是完美主义者,可以彻底处理干净后在进行提交!(我解决了,您随意!)提交代码
创建并提交 tag
git tag -a 0.1.0 -m '创建 pod 库' git push origin --tags
注意: 此处的
tag
应与.podspec
文件中的s.version
保持一致。每次修改pod
中的代码,添加tag
后,都应同时修改.podspec
文件中的s.version
提交 pod
恭喜您,您已经成功的将您创建的 pod 库推送到了官方 pod 库!
坑点 & 解决方案
Failed to open TCP connection to trunk.cocoapods.org:443 (getaddrinfo: nodename nor servname provided, or not known)
解: 此问题常见于
pod trunk
相关的命令。网络大环境不行,要么呢啥(技术都懂的),要么连接手机开热点进行操作。Unable to accept duplicate entry for: YOURPODNAME (0.1.0)
解:
pod trunk push
时发生此错误,说明该pod
库在远端已经有了 0.1.0 版本。解决方案有两个:pod trunk delete YOURPODNAME 0.1.0
删除远端的 0.1.0 版本,然后重新进行推送unable to find a pod with name, author, summary, or description matching 'YOURPODNAME'
解: 信息更新不及时导致。
首先删除本地缓存
rm ~/Library/Caches/CocoaPods/search_index.json
然后执行:
Beta Was this translation helpful? Give feedback.
All reactions