主要步骤
1.代码上传Github
2.创建podspec文件,并验证是否通过
3.在Github上创建release版本
4.注册CocoaPods账号
5.上传代码到CocoaPods
1.代码上传Github
打开https://github.com/
注册并创建代码仓库
如下图所示

创建工程代码,然后上传到gitHub,文件夹目录如下所示:

都是比较通用的步骤,一般不会有什么问题。
2.创建podspec文件,并验证是否通过
使用终端进入工程目录
执行命令
//创建podspec文件
pod spec create biu_SCMark.podspec

执行完毕后会在文件目录中出现此文件

接下来就是编辑podspec文件,里面规定了很多字段都要填写正确
比如这个版本号s.version = "1.0.3",要和自己项目的tag对应上,如果没有相应的tag,就会报错。所以要提前打好tag
Pod::Spec.new do |s|
s.name = "biu_SCMark"
s.version = "1.0.3"
s.summary = "good way to add corner mark"
s.description = <<-DESC 'biu_SCMark'
DESC
s.homepage = "https://github.com/biubiublue/SuperCornerMark.git"
s.license = "MIT"
s.author = { "biubiublue" => "utopia.pro@aliyun.com" }
s.platform = :ios
s.ios.deployment_target = "8.0"
s.source = { :git => "https://github.com/biubiublue/SuperCornerMark.git", :tag => "#{s.version}" }
s.source_files = 'SCMark/*.{h,m}'
s.frameworks = 'Foundation', 'UIKit'
s.requires_arc = true
end
接下来要验证podspec文件
在终端中输入如下命令
pod lib lint biu_SCMark.podspec
如果报错比如:
因为s.frameworks = 'Foundation', 'UIKit'写的不对

如果只是报警,可以使用命令忽略

执行命令
pod lib lint biu_SCMark.podspec --allow-warnings
看到如下显示,说明验证成功了。

3.在Github上创建release版本
这一步在github上操作,找到对应的仓库,点击Release 然后发布。
比较简单,一般都没有问题。
4.注册CocoaPods账号
执行命令
//好像不加描述信息也可以
pod trunk register 邮箱地址 ‘用户名’ —description='描述信息'
执行成功后,会有提示往你邮箱发了一封邮件,需要验证一下,进入邮箱点击一下就可以。

这样就注册成功了
可以使用命令
pod trunk me
来验证自己的信息
5.上传代码到CocoaPods
先验证podspec
pod lib lint biu_SCMark.podspec
//有警告的话使用
pod lib lint biu_SCMark.podspec --allow-warnings
验证成功后
push到Cocoapods
pod trunk push biu_SCMark.podspec --allow-warnings
成功后显示

这样别人就可以使用你的代码了
网友评论