這裏有個坑首先須要注意,建立私有cocoapods倉庫須要兩個git倉庫,即代碼倉庫,Specs文件倉庫.git
1、建立私有庫github
1.建立本身源碼倉庫,假設是A.git;測試
2.對A倉庫:spa
git add .資源
git commit -m "commit msg"源碼
git tag -a 1.0.0it
git push tag -all編譯
3.建立Specs倉庫B.git;class
4.添加私有repo到CocoaPods中:date
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
2、使用私有庫
1.在須要使用私有庫的項目中,編輯podFile:
source 'B.git'
pod 'A'
2.終端中pod install 便可
3、高級
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