一、创建podspec索引仓库,创建源文件仓库
在自己私有git分别创建上述两个仓库,如果有则不用创建
二、将podspec索引仓库添加到本地pod repo
在终端执行下述命令即可
pod repo add xxxSpecs 仓库地址
注: 1.其中xxxSpecs为本地资源文件夹名称,建议与仓库名称一致
2.仓库地址是自己在第一步创建的索引仓库地址
三、克隆源文件仓库并编写项目源码
四.在工程目录下创建podspec文件(注:需在同级目录下创建一个LICENSE文件)
创建podspec文件
1.移动到源文件工程目录 cd XXX/XXXX/XXXXX
2.在该目录下执行创建podspec文件命令
pod spec create [name] 注:[name]就是项目名称
3.在远程仓库的同级目录下创建LICENSE文件 注:使用MIT模板
4.在本地仓库进行更新刚才在远程仓库创建的文件
五、podspec文件每个字段的含义
Pod::Spec.new do |s|
s.name = “xxx” 开源库的名称
s.version = “0.0.17″ 开源库版本
s.summary = “xxxx” 摘要
s.description = <<-DESC 描述
天利和工具类,里面具有时间,弹框,视图等处理方法
DESC
s.homepage = “http://xxxx/ios/xxxxProduct” 开源库首页
s.license = “MIT” 开源库协议文件
# s.license = { :type => “MIT”, :file => “FILE_LICENSE” }
s.author = { “xx” => “xx@qq.com” } 开源库作者
s.platform = :ios, “9.0″ 开源库平台以及版本
s.source = { :git => “http://xxxx/ios/xxxxProduct.git”, :tag => “#{s.version}” } 开源库源码地址
# s.public_header_files = “Classes/**/*.h” 源码需要的头文件
s.subspec ‘UtilityClass’ do |utilityClass| 定义一个子模块
utilityClass.source_files = ‘xxxxClass/xxxxxClass/UtilityClass/*.{swift}’ 开源库(子模块)源文件
end
s.subspec ‘LoginMoudle’ do |loginMoudle|
loginMoudle.source_files = ‘xxxxClass/xxxxClass/LoginMoudle/*.{swift}’
loginMoudle.dependency ‘xxxxxClass/UtilityClass’ 需要依赖的第三方库
loginMoudle.resource_bundles = {‘xxxxClass’ => [“xxxxClass/xxxxClass/LoginMoudle/LoginMoudle.bundle”,”xxxxClass/xxxxClass/LoginMoudle/*.{storyboard}”]} 开源库(子模块)资源文件
end
end
六、提交源文件,podpsec,并打上tag(该tag与podspec里面的版本一致)
七、检验podspec是否合格
1.移动到podspec所在目录 cd XXX/XXXX/XXXXX
2.执行命令:pod spec lint [name].podspec —verbose
3.出现下述字样就是合格
八、发布podspec到私有仓库
在第七步完成之后继续执行命令
pod repo push xxxSpecs xxxx.podspec
xxxSpecs是第二步添加到本地的repo文件夹名称