如何将自己的项目发布到cocoapods
让别人更加方便的使用,总结起来其实总共就4个步骤:
创建podspec文件、验证github仓库、登录(注册)cocoapods、发布到cocoapods。
具体步骤如下:
一、你可能需要先进行如下操作步骤
1.更新github的master分支
1. 修改本地podspec文件信息
2. $git add .
3 $git commit
4. $git push origin master
2.为当前分支添加tag
5. $git tag -a [tagname] -m 'note'
6. $git push origin [tagname]
二、具体操作
1. $ pod spec create [NAME]
按照以下格式修改podspec文件,你可以直接拷贝改代码进行修改
Pod::Spec.new do |s|
s.name = "WJPhotoBrowser"
s.version = "1.1.3"
s.summary = "A simple and easy to use image browser."
s.homepage = "https://github.com/ZengWeiJun/WJPhotoBrowser"
s.license = "MIT"
s.author = { "zwj" => "niuszeng@sina.com" }
s.platform = :ios, "7.0"
s.source = { :git => "https://github.com/ZengWeiJun/WJPhotoBrowser.git", :tag => s.version }
s.source_files = "WJPhotoBrowser", "WJPhotoBrowser/*.{h,m}"
s.resources = "WJPhotoBrowser/images/*.png"
s.framework = "UIKit"
s.requires_arc = true
s.dependency 'SDWebImage', '~> 3.7.2'
s.dependency 'MBProgressHUD', '~> 0.9.1'
end
将该文件上传至github,再给git仓库打上一样版本的tag
2.$ pod spec lint [NAME.podspec]
验证podspec文件,如果出现not pass关键字说明未通过,按照提示修改
3.$ pod trunk register sheep@cocoapods.org 'Sheep' --description='macbook pro'
这里sheep@cocoapods.org是你自己的邮箱,可能会有一个邮箱验证过程,请检查邮箱未读信息, ‘Sheep’ 和 ‘macbook pro’ 均为自定义内容
4.$ pod trunk push [NAME.podspec]
发布,成功以后可以使用pod search 命令搜索到自己项目
如果是更新版本,省略创建podspec步骤,从修改podspec以后步骤相同