CocoaPods 创建私有库
2020-04-08 本文已影响0人
一个魔法师
一、新建项目
- 创建远程仓库(这里以github为例子)
- clone下来
- 创建项目
- 新建放置pod库配置文件的远程仓库
二、新建本地pod库
- 添加本地pod仓库
- git pod repo add 本地仓库名称 上面创建放置配置文件的git地址
三、新建.podspec文件
-
在clone下来的仓库的根目录下(不在根目录也行)创建.podspec结尾的文件
-
添加配置
Pod::Spec.new do |s| s.name = "Artsy+OSSUIFonts" //版本号,亦是将来你的私有工程要打上的tag号 s.version = "1.1.1" s.summary = "The open source fonts for Artsy apps + UIFont categories." s.homepage = "https://github.com/artsy/Artsy-OSSUIFonts" s.license = 'Code is MIT, then custom font licenses.' s.author = { "Orta" => "orta.therox@gmail.com" } s.source = { :git => "https://github.com/artsy/Artsy-OSSUIFonts.git", :tag => s.version } s.social_media_url = 'https://twitter.com/artsy' s.platform = :ios, '7.0' s.requires_arc = true s.source_files = 'Pod/Classes' s.resources = 'Pod/Assets/*' s.frameworks = 'UIKit', 'CoreText' s.module_name = 'Artsy_UIFonts' end
四、项目提交打上tag
- 项目提交远程仓库
- 打上tag(上面.podspec对应的tag号)
五、验证
- cd 到.podspec文件的目录下
- pod repo lint .
- 有问题的按照提示处理问题
- pod repo push 项目名称 xxx.podspec
- 恭喜!大功告成 去项目中pod 吧,不过需要注意要指定你的pod库的远程配置文件的路径,也就是source xxxxxxxx
六、pod库升级
- 修改项目,提交项目,打上tag
- 修改.podspec文件对应的版本号
- pod repo push 项目名称 xxx.podspec --verbose --use-libraries --allow-warnings
七、遇到的一些小坑
-
本地pod库被删了,无法pod repo push,只需要再执行一遍
git pod repo add 本地仓库名称 上面创建放置配置文件的git地址
-
pod库升级后,新的项目中引入的还是旧的库版本,需更新下本地的repo
pod repo update