一、創建私有庫索引
在碼云建立一個私有庫索引,起名為TKComponentSpec
image.png
二、本地添加私有庫索引
- 添加私有庫索引
pod repo add TKComponentSpec https://gitee.com/libtinker/tkcomponent-spec.git
-
查看本地私有庫索引
image.png
三、創建功能組件庫
當你新建自建的時候,就從這里開始
- 在碼云上創建組件庫,命名為TKKit,如下圖:
image.png
- 創建TKKit本地庫
pod lib create TKKit
- 在私有庫中導入自己的代碼
在class文件下面導入自己的代碼文件,并刪除ReplaceMe.m文件
image.png - 更新整個工程的pod庫
1.cd到Example文件下
2.執行 pod install - 修改.podspec文件
image.png
image.png
有兩個屬性需要修改:
s.homepage:私有庫地址
s.source:私有庫源碼地址 - 將私有庫push到遠程倉庫
cd 到私有庫
git branch master
git checkout master
git status (檢查當前的git存了什么文件)
git add . (將所有文件緩存到待提交文件區域)
git commit -m "上傳組件"
git remote add origin https://gitee.com/libtinker/tkkit.git (私有庫索引)
git push -f origin master (提交代碼到遠程倉庫master分支上)
git tag 0.0.1 (這里的版本號必須和podspec里面的一致)
git push --tag (提交tag)
- 本地和遠程校驗
1.本地私有庫校驗:
pod lib lint --private --allow-warnings
校驗成功:TKKIt passed validation
2.遠程私有庫驗證:
pod spec lint --private --allow-warnings
校驗成功:TKKIt.pidspec passed validation
- 提交索引文件到遠程索引庫
1.檢查沒問題后,提交索引文件到遠程索引庫
私有庫
pod repo push TKComponentSpec TKKit.podspec --allow-warnings
公有庫
pod trunk push TKStackCard.podspec --allow-warnings
2.推送之后到本地索引庫中查看
image.png
3.在遠端getee上查看
image.png
四、私有庫使用
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
source 'https://gitee.com/libtinker/tkcomponent-spec.git'
target 'TestDemo' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
pod 'TKKit'
end