1、cd 到项目根目录
cd xxx
2、创建.podspec文件,xxx最好和项目名称一致
pod spec create xxx
3、编辑.podspec文件
Pod::Spec.new do |s|
s.name = "仓库名称"
s.version = "版本号"
s.summary = "概述"
s.description = "详细描述 "
s.homepage = "仓库网址" //区别于git地址
s.license = { :type => "MIT", :file => "LICENSE" }
s.author = { "作者名称" => "邮箱地址" }
# 支持平台
s.ios.deployment_target = "8.0"
#仓库地址 (不要使用ssh)
s.source = { :git => "https://*****/*****/****.git", :tag => "#{s.version}" }
# 源文件位置,
# 可以在项目根目录下建个文件夹,文件夹内建两个文件夹Classes和Assets
s.source_files = 'xxx/Classes/*.{h,m}'
# 三方的framework文件
# s.ios.vendored_frameworks = 'xxx/Assets/*.framework'
# 三方的.a文件
# s.ios.vendored_libraries = 'xxx/Assets/*.a'
# 图片、bundle等资源文件
s.resources = "xxx/Assets/*.{png,xib,nib,bundle}"
# 需要的framewoke,多个用逗号分开
s.frameworks = "UIKit", "Foundation"
# 是否arc
s.requires_arc = true
# 依赖的三方库,如果有多个分开写,后面的版本号可以不写,不写就是最新版本
# s.dependency "JSONKit", "~> 1.4"
# s.dependency "AFNetworking"
end
4、为代码打tag,这步很重要
git tag '1.0.0'//必须和podspec文件内的s.version一致,否则无法push到cocoapods
git push --tags
5、注册trunk,只需注册一次
- 第一次注册邮箱和用户名都必须填写;
- 如果注册成功后想修改用户名必须使用新邮箱+新用户名,如果不加用户名则是替换邮箱;
- 注册过的邮箱无法修改用户名,切记。
pod trunk register 邮箱 用户名
6、PSUH到cocoapods
pod lib lint --allow-warnings
pod trunk push --allow-warnings
提交成功显示
? Congrats
? 仓库名称 (版本号) successfully published
? February 7th, 21:33
? https://cocoapods.org/pods/仓库名称
? Tell your friends!
和cocoapods关系密切的网址
- 查看到刚刚提交的记录
https://github.com/CocoaPods/Specs/tree/master/Specs - 搜索三方库,如果搜索到,说明已经审核成功,可以使用了
https://cocoapods.org/ - 认领pod
https://trunk.cocoapods.org/claims/new