- 创建索引库(如果是推到公共库,略过)
- 远程git仓库上创建项目(coding、github)
- pod repo add [库名] [git地址]
- ps:这个库是私有库的索引库,存储所有私有库的.podspec文件,不存储具体代码。
- 创建组件库
- 通过模板快速创建.pod lib create [工程名]
- 如图提示缺少colored2,使用sudo gem install colored2 安装
- 配置.podspec文件
- 看参考知名的第三方框架
Pod::Spec.new do |s|
s.name = "JLRoutes"
s.version = "2.1"
s.summary = "URL routing library for iOS with a simple block-based API."
s.homepage = "https://github.com/joeldev/JLRoutes"
s.license = "BSD 3-Clause \"New\" License"
s.author = { "Joel Levin" => "joel@joeldev.com" }
s.source = { :git => "https://github.com/joeldev/JLRoutes.git", :tag => "2.1" }
s.framework = 'Foundation'
s.requires_arc = true
s.source_files = 'JLRoutes', 'JLRoutes/*.{h,m}', 'JLRoutes/Classes/*.{h,m}'
s.ios.deployment_target = '8.0'
s.osx.deployment_target = '10.10'
s.tvos.deployment_target = '9.0'
end
打版本号。pod tag [版本号] git push --tags
注意点:可能会有配置子模块的需求,但在实践下来后,不建议这么操作。推荐分成多个私有库。因为Example中是这么引入的pod 'ZHMediator', :path => '../',配置子库后,进行pod install后,目录冗余。
- 验证podspec有效性
- pod lib lint本地验证(不会验证版本号)
- pod spec lint远程验证(需要打好正确的版本号)
- 向索引库提交索引文件
5.1 如果是私有库
pod repo push [索引库名][要提交的索引文件.podspec].如果依赖了非公有库的源,依赖了library,需要参数中指定源.--sources=[git地址],[第二个索引库]--use-libraries.
5.2 如果是公有库
- pod trunk register [邮箱]
邮箱中会收到一封验证邮件,点击后提示回到控制台 - pod trunk push