cocopods私有库


title: iOS创建私有仓
grammar_cjkRuby: true


第一步, 添加远程私有索引仓库
1.打开终端, 输入指定 pod repo

 master
- Type: git (master)
- URL:  https://github.com/CocoaPods/Specs.git
- Path: /Users/tianmingfu/.cocoapods/repos/master

2.输入 pod repo add 仓库名 仓库SSH(HTTPS)地址 来添加一个远程索引仓库(pod repo remove xxx"来删除多余的repo)
pod repo add MJPodSpecs https://gitee.com/tianmingfu/MJPodSpecs.git

3.再次输入 pod repo 命令 多了MJPodSpecs 成功添加MJPodSpecs远程私有索引库
[图片上传失败...(image-26ca03-1547805964641)]

第二步, 配置一个私有的代码仓库
1.打开gitlab, 新添加项目, 这个项目是被CocoaPods管理的私有代码仓库, 用来存储需要被管理的代码, 和上面创建的索引库用处不同
2.终端输入:~ cd Documents/MJCommonModule
3.输入指令创建一个git本地仓库 pod lib create 仓库名输入指令创建一个git本地仓库 pod lib create 仓库名

pod lib create MJCommonModule

4.如图对应输入
[图片上传失败...(image-6c875d-1547805964641)]
5.git仓库用来测试和上传私有代码
6.找到需要CocoaPods私有仓库管理的源码(我这里的是Category文件夹), 并拖拽代码文件到Classes文件夹中, 选择Copy Items if needed
[图片上传失败...(image-c468c6-1547805964641)]
7.[图片上传失败...(image-22f764-1547805964641)]
[图片上传失败...(image-8d7d24-1547805964641)]

8.cd到测试工程文件夹Example, 并执行命令 pod install
此时拖入工程的Class中文件就可以正常使用了, 此时使用的是本地私有库

9.打开测试工程,在下面的位置进行podspec配置
注意
s.homepage需要设置刚创建的私有代码仓库的地址, 不是私有索引库的地址
s.source 需要设置的是私有代码仓库的源地址(选择使用HTTPS地址)
[图片上传失败...(image-e5a417-1547805964641)]

[图片上传失败...(image-8aac11-1547805964641)]

10.将刚创建的本地仓库上传到这个项目中, 并打上tag, 这个tag必须和上面podspec文件中的版本一致(我上面的版本是0.1.0, 所以我打的tag就是0.1.0)

git  add .
git commit -m "提交描述"
git remote add 

git remote add origin https://gitee.com/tianmingfu/MJCommonModule.git

git pull origin master
git push origin master

git tag -a 'tag版本' -m '版本描述'
git push origin --tags (删除git tag -d tag名)

11.cd 到项目 这个文件夹

使用pod lib lint  本地校验
使用pod spec lint 远程校验

[图片上传失败...(image-6e09ce-1547806039770)]

12.cd 至 MJCommonModule 文件夹下, 接着执行 pod repo push 索引库名 podspec文件名
pod repo push MJPodSpecs MJNetwork.podspec

猜你喜欢

转载自blog.csdn.net/weixin_34006468/article/details/86923068
今日推荐