IOS搭建本地私有库
2020-03-12 本文已影响0人
lenka01
IOS搭建本地私有库
Cocoapods的安装
这里直接采用命令安装比较方便
sudo gem install cocoapods
创建一个私有索引库
- 准备一个私有库地址,内部有权限限制的仓库即可。
https://rdc.hand-china.com/gitlab/10100/PrivateReposStore.git
- 添加关联本地私有库和远端私有库地址
pod repo add wangshengTestStore https://rdc.hand-china.com/gitlab/10100/PrivateReposStore.git
Cocoapods私有库创建
创建私有库模板
pod lib create repoDemo
过程如下:

安装完之后会自动打开项目

编写组件库代码
把核心的代码拖入到Class文件夹中去
这里我以TestClass.h为例,目录下的ReplaceMe.m文件夹可以删除掉。
然后进入Example文件夹,首次使用pod install进行安装,然后可以正常的引用和写测试代码

组件库代码提交到git上
git remote add origin 项目地址
git push -u origin master
git tag -m "0.1.0" 0.1.0
git push --tags
向索引库提交spec
我们使用如下两行命令分别进行验证检查本地和远程,这里我们把警告忽略掉。
pod lib lint --allow-warnings
pod spec lint --allow-warnings
然后执行如下命令添加到spec中去
pod repo push wangshengTestStore privateLibDemo.podspec
如果出现The privateLibDemo.podspec specification does not validate.错误
pod repo push wangshengTestStore privateLibDemo.podspec --verbose --use-libraries --allow-warnings

到此告一段落,可参考https://guides.cocoapods.org/