发布自己的开源项目分几步:
一、把自己的项目上传到github上
(1)在github上新增一个repository
需要注意的是,cocoapods要求添加一个license文件
(2)新建一个文件夹,从github上clone 项目到该文件夹下,添加开源项目拷贝到该文件夹下
(3)设置git的tag(cocoapods要求)
终端:
创建tag: git tag 1.0
提交tag到github: git push origin --tags
二、创建.podspec文件
终端:
(1)进入到项目下:$cd ~/path
(2)创建.podspec文件:$pod spec create 项目名
(3)编辑.podspec文件
如:
Pod::Spec.new do |s|
s.name = "Test"
s.version = "1.0"
s.summary = "A test Project"
s.homepage = "https://github.com/.../Test"
s.license = "MIT"
s.license = { :type => "MIT", :file => "LICENSE" }
s.author = { "...@qq.com" => "...@qq.com" }
s.platform = :ios, '9.0'
s.source = { :git => "https://github.com/.../TestGit2.git", :tag => "1.0"}
s.source_files = "Test", "Test/**/*.{h,m}"
s.frameworks = "UIKit","XCTest"
s.requires_arc = true
end
(4)验证.podspec文件
终端:$pod spec lint Test.podspec
若是验证成功,提交.podspec文件到github,若是有错误或是警告继续修改直到没有为止
三、发布项目到cocoapods
(1)注册truck 终端:$pod trunk register ...@qq.com 'ouyang' --description='macbook air'
(2) 收到邮件去激活
(3) 发布项目:$pod trunk push Test.podspec --allow-warnings
成功的话 有提示