1>注册这台MAC可以发布POD
$ pod trunk register targetcloud@163.com "targetcloud"
[!] Please verify the session by clicking the link in the verification email that has been sent to targetcloud@163.com
去邮箱点击一下验证链接,出现下面页面表示通过
2>查看自己的信息
$ pod trunk me
- Name: targetcloud
- Email: targetcloud@163.com
- Since: March 3rd, 02:13
- Pods: None
- Sessions:
- March 3rd, 02:13 - July 9th, 02:31. IP: 112.64.216.106
3>查看可以使用的组件名
$ pod search TGLabel
Creating search index for spec repo 'master'.. Done!
[!] Unable to find a pod with name, author, summary, or description matching `TGLabel`
4>创建仓库、创建工程
去github创建仓库后,复制链接到SourceTree,Xcode创建工程TGLabelDemo,同级目录创建TGLabel
$ cd /Users/targetcloud/Desktop/TGLabel/TGLabelDemo
$ ls
TGLabelDemo TGLabelDemo.xcodeproj
5>创建podspec
$ pod spec create https://github.com/targetcloud/TGLabel
6>修改podspec
Pod::Spec.new do |s|
s.name = "TGLabel"
s.version = "0.0.1"
s.summary = "TGLabel"
s.homepage = "https://github.com/targetcloud/TGLabel"
s.license = "MIT"
s.author = { "targetcloud" => "targetcloud@163.com" }
s.platform = :ios, "8.0"
s.source = { :git => "https://github.com/targetcloud/TGLabel.git", :tag => s.version }
s.source_files = "TGLabelDemo/TGLabel/**/*.{swift,h,m}"
s.requires_arc = true
end
7>支持swift3
$ echo 3.0 > .swift-version
8>倒数第二步,用于检查是否可以push了
$ pod spec lint
-> TGLabel (0.0.1)
Analyzed 1 podspec.
TGLabel.podspec passed validation.
9>最后一步,用于push
$ pod trunk push
[!] Found podspec `TGLabel.podspec`
Updating spec repo `master`
坑点:pod spec lint对s.source_files的检查并不仔细,会导致验证虽然通过了,但是到了pod trunk push仍然会出错,常见的错误如下
[!] Failed to connect to GitHub to update the CocoaPods/Specs specs repo - Please check if you are offline, or that GitHub is down
[!] There was an error pushing a new version to trunk: Net::OpenTimeout