想Pods管理抽取出的项目代码,且只想让团队内不使用。今天我们就来创建 iOS 私有库。[官方教程 - Private Pods ]
一,创建 iOS 私有库
1.1 在公司内部GitLab上创建 iOS 私有库 CheGuoSpecs 。

点击 Create project , GitLab的私有库就创建完成啦
1.2 在本地库中创建CheGuoSpecs私有库
在终端执行创建命令: pod repo add CheGuoSpecs http://10.10.13.28/iOS/CheGuoSpecs.git

二,创建 公共模块
2.1 在GitLab上创建 iOS 公共模块 OneProj

点击 Create project。然后将抽取出来的 并在文件中添加 LICENSE 文件。
2.2 在OneProj 根路径下创建spec文件
执行创建命令:pod spec create OneProj 。项目根路径下会生成 OneProj.podspec 文件。

1. 填写协议后需要在项目中存在 名为 LICENSE 的文件
2. 私有库项目要根据 tag 生成,所以项目中要存在 tag。
3. 将公共模块 OneProj 上传到 GitLab。命令如下:
cd OneProj
git init
git remote add origin git@10.10.13.28:iOS/OneProj.git
git add .
git commit
git push -u origin master
2.3 验证修改后的 OneProj.podspec 文件。
执行命令: pod lib lint

如图所示说明OneProj.podspec 修改正确。
2.4 上传公共模块到私有库中
1.生成私有库前需要创建 tag,且与 OneProj.podspec 文件中的 s.version 一致。
创建 tag 。执行下面命令:
git tag '0.0.1'
git push --tags

2.5上传公共模块到私有库中
执行命令:pod repo push CheGuoSpecs OneProj.podspec

查看本地库

查看远程库

三,验证与使用
3.1 检索项目
执行命令: pod search OneProj

如图说明私有库已经创建成功
3.2 使用私有库中公共模块
先创建一个 iOS 项目 OneProjDemo , 在项目根路径 执行命令: pod init
修改生成的 Podfile 文件

1. 添加私有库路径 http://10.10.13.28/iOS/CheGuoSpecs.git
2. 添加 pod 'OneProj'
进入项目执行命令: pod install

查看项目

到此私有库创建就完成了。iOS项目成员可以参考 OneProj 公共组件来添加公共模块
网友评论