1.Cocoapods 使用pod trunk发布程序
2.Framework的CocoaPods制作
1.注册
$ pod trunk register '邮箱' '用户名' --description='电脑描述'
例如:
$ pod trunk register 'jeiker@126.com' 'jeikerxiao' --description='mac pro'
[!] Please verify the session by clicking the link in the verification email that has been sent to jeiker@126.com
2.查收邮件
如果是QQ邮箱,可能会被放到“垃圾箱”中,并不一定是“收件箱”
点击邮件中的链接:
https://trunk.cocoapods.org/sessions/verify/xxxx
3.接下来查看个人信息
$ pod trunk me
结果信息:
- Name: jeikerxiao
- Email: jeiker@126.com
- Since: January 11th, 01:43
- Pods: None
- Sessions:
- January 11th, 01:48 - June 5th, 04:34. IP: xxx.xxx.xxx.xxx Description: Macbook Pro
1.中间可能遇到这种错误:
NoMethodError - undefined method 'last' for #<Netrc::Entry:0x007fc59c246378>
这时候需要尝试更新gem源或者pod:
$ sudo gem update --system
$ sudo gem install cocoapods
$ sudo gem install cocospods-trunk
2.如果遇到这种情况:
[!] Authentication token is invalid or unverified. Either verify it with the email that was sent or register a new session.
解决方案:
重新执行第一步注册。重来。
4.创建podspec文件
接下来需要在项目根路径创建一个podspec文件来描述你的项目信息
$ pod spec cretae 文件名
比如
pod spec cretae XXPickerView
就会生成一个XXPickerView.podspec
5.填写podspec内容
Pod::Spec.new do |s|
s.name = 'XXPickerView'
s.summary = 'ActionSheet with UIPickerView.'
s.version = '1.0.0'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.authors = { 'jeikerxiao' => 'jeiker@126.com' }
s.homepage = 'https://github.com/jeikerxiao/XXPickerView'
s.ios.deployment_target = '7.0'
s.source = { :git => 'https://github.com/jeikerxiao/XXPickerView.git', :tag => s.version.to_s }
s.requires_arc = true
s.source_files = 'XXPickerView/*.{h,m}'
s.public_header_files = 'XXPickerView/*.{h}'
s.frameworks = 'Foundation', 'CoreFoundation', 'UIKit', 'QuartzCore'
end
值得注意的是,现在的podspec必须有tag,所以最好先打个tag,传到github
$ git tag 0.0.1
$ git push --tags
6.检测podspec语法
$ pod spec lint XXPickerView.podspec
如果出现以下问题:
Could not resolve host: github.com
问题原因:因为github.com没有被主机给解析。
解决方法:
1.找到github.com的IP地址:
ping github.com
PING github.com (192.30.255.112): 56 data bytes
64 bytes from 192.30.255.112: icmp_seq=0 ttl=43 time=144.449 ms
2.编辑文件etc/hosts
sudo vi /etc/hosts
按:i 启动编辑模式。
在hosts文件最后增加一行:添加github的地址
192.30.255.112 github.com
按:esc 退出编辑模式。
按::wq 退出vi。
7.发布podspec
$ pod trunk push XXPickerView.podspec
发布时可以允许警告:
$ pod trunk push --allow-warnings XXPickerView.podspec
8.检测
初始化:
$ pod setup
更新仓库:
$ pod repo update
查询上传的版本:
$ pod search XXPickerView
9.仓库更新
如果仓库更新慢,可以考虑更换仓库镜像
$ pod repo remove master
$ pod repo add master http://git.oschina.net/akuandev/Specs.git
10.命令
$ pod trunk COMMAND
Usage:
$ pod trunk COMMAND
Interact with the CocoaPods API (e.g. publishing new specs)
Commands:
+ add-owner Add an owner to a pod
+ delete Deletes a version of a pod.
+ deprecate Deprecates a pod.
+ info Returns information about a Pod.
+ me Display information about your sessions
+ push Publish a podspec
+ register Manage sessions
+ remove-owner Remove an owner from a pod
Options:
--silent Show nothing
--verbose Show more debugging information
--no-ansi Show output without ANSI codes
--help Show help banner of specified command