首页 > 技术文章 > CocoaPods 创建私有仓库

dokaygang128 2015-12-08 22:06 原文

这里有个坑首先需要注意,创建私有cocoapods仓库需要两个git仓库,即代码仓库,Specs文件仓库.

一、创建私有库

1.创建自己源码仓库,假设是A.git;

2.对A仓库:

git add .

git commit -m "commit msg"

git tag -a 1.0.0

git push tag -all

3.创建Specs仓库B.git;

4.添加私有repo到CocoaPods中:

pod repo add B B.git

5.进入A仓库的目录创建Specs文件:

pod spec create A A.git

此时A仓库目录下有A.podspec文件;

6.编辑A.Spec文件;

7.A目录下验证A.Spec:

pod lib lint --verbose --allow-warnings

8.提交Spec:

pod repo push B A.podspec

 

二、使用私有库

1.在需要使用私有库的项目中,编辑podFile:

source 'B.git'

pod 'A'

2.终端中pod install 即可

 

三、高级

1.若私有cocoapods A 依赖另一个私有cocoapods C:

pod spec lint --verbose --allow-warnings --sources='C_Specs.git,https://github.com/CocoaPods/Specs'

其中C_Specs.git是私有cocoapods C的Specs文件仓库地址;

2.若私有cocoapods中含有xib文件,需要将xib文件作为资源文件,而不能作为源码文件,否则导入安装后会编译不过。

s.resources = ["images/*.png", "classes/MyView.xib"];

3.方便测试当前库源码是否OK:

在使用私有cocoapods的仓库中,

修改pod 'A' 为 pod 'A', :path => 'XXXXXX'      #指定路径,其中XXXXX为A仓库的本地路径。

然后执行:pod update

推荐阅读