1.在GitLab上創建一個遠程索引私有庫,即:創建一個私有工程 名稱爲PrivateRepo
2.將遠程索引庫地址加入repo
命令: pod repo add PrivateRepo http://xxxxxxx/xxxxxx/PrivateRepo.git
注意:PrivateRepo 爲私有庫名稱 http://xxxxxxx/xxxxxx/PrivateRepo.git爲私有庫地址
3.創建本地組件工程
命令:pod lib create ComponentPro
注意:ComponentPro 爲組件工程名稱
4.在GitLab上創建組件工程遠程庫,即創建一個私有工程 名稱爲ComponentPro
5.將組件工程遠程庫與本地組件工程做關聯同步
cd ComponentPro
git add .
git commit -m '初始化'
git remote add origin http://xxxxx/xxxxx/ComponentPro.git
6.修改組件工程的spec文件
s.version = '0.1.0'
s.summary = '組件描述'
s.homepage = 'http://xxxxxxx/xxxxxxx/ComponentPro'
s.source = { :git => 'http://xxxxxx/xxxxx/ComponentPro.git', :tag => s.version.to_s }
注意:s.version 爲版本號 一定要與 組件工程的tag一致,否則會報錯
s.summary 組件的描述文字放在這裏
s.homepage 網頁網址搜索欄裏面的地址
s.source 組件工程的遠程地址
7.把修改進行提交併更新到遠程倉庫
git add .
git commit -m '修改spec文件'
git push origin master
8.驗證本地spec文件
pod lib lint
9.提交版本tag
git tag 0.1.0
git push --tags
注意:git tag 0.1.0必須要與組件中 s.version= '0.1.0'的版本號一致
10.驗證遠程sppec文件
pod spec lint
11.將組件工程的spec文件推送到遠程索引庫
pod repo push PrivateRepo ComponentPro.podspec
注意:PrivateRepo爲遠程索引庫的名稱;ComponentPro.podspec爲組件工程裏的spec文件
12.修改宿主工程的podfile
cd /Users/xxxx/Desktop/MyProject/MyProject
pod init
pod install
修改出現的podfile文件
注意:修改爲如下
source 'http://xxxxx/xxxxx/PrivateRepo.git'
source 'https://github.com/CocoaPods/Specs.git'
target 'MyProject' do
pod 'ComponentPro'
end
注意:http://xxxxx/xxxxx/PrivateRepo.git 爲存放索引庫的地址
https://github.com/CocoaPods/Specs.git 這個地址不要動,就寫這個
13.安裝
pod install
14.查看MyProject工程中的Pods中出現了我們製作的組件私有庫