本地索引文件
~/Library/Caches/CocoaPods/search_index.json
创建CocoaPods远程私有库大体流程如下:
a.创建索引库项目,并获取仓库地址。(如:https://git.coding.net/herui/HHSpecs.git)
b.本地添加私有索引库:pod repo add HHSpecs https://git.coding.net/herui/HHSpecs.git
e.创建私有库项目,获取仓库地址。(如:https://git.coding.net/herui/HHCategory.git)
c.本地创建私有pod库:pod lib create HHCategory
d.修改HHCategory.podspec文件相关配置。(如s.version
、s.description
、s.source
等)
e.提交私有库,创建并提交tag。
f.提交本地pod项目到索引库:pod repo push HHSpecs HHCategory.podspec
g.Podfile文件指定索引库地址:
source 'https://git.coding.net/herui/HHSpecs.git'
source 'https://github.com/CocoaPods/Specs.git'
h.pod install 即可正常使用
下面是具体流程:
Coding创建两个项目:用于存放pod索引库HHSpecs
以及pod库HHCategory
。
![](https://img.haomeiwen.com/i555436/db2ec1a7dbd7fd26.png)
![](https://img.haomeiwen.com/i555436/2c620adde7987771.png)
回到终端,添加索引库:
pod repo add HHSpecs https://git.coding.net/herui/HHSpecs.git
![](https://img.haomeiwen.com/i555436/4b9b63fe0a23cdeb.png)
创建pod项目:
pod lib create HHCategory
![](https://img.haomeiwen.com/i555436/e73c58b8467e19a3.png)
成功后Xcode自动打开HHCategory-Example项目,
a.编辑HHCategory->Podspec Metadata->HHCategory.podspec文件,注意s.source即pod库地址、tag同s.version。
b.用自己的类文件替换掉Pods->Development Pods->HHCategory->HHCategory->Casses->ReplaceMe.m
如图:
![](https://img.haomeiwen.com/i555436/b3efc935c7823425.png)
提交pod项目到远程仓库。注意需要提交tag,且tag同上图中的s.version
![](https://img.haomeiwen.com/i555436/814e05af54b4a3e0.png)
提交本地pod项目到索引库:pod repo push HHSpecs HHCategory.podspec
![](https://img.haomeiwen.com/i555436/4ddbb1718e28cdd4.png)
到这里私有库就创建完毕,下面创建测试项目开始使用:
pod init
命令创建Podfile文件,其中因为HHCategory是私有库,所以需要指定source
![](https://img.haomeiwen.com/i555436/44d87a2306fbde2a.png)
pod install
安装
![](https://img.haomeiwen.com/i555436/29272ade1b88dcd4.png)
大功告成哦耶~
网友评论