iOS搭建組件化私有庫

一、創建私有庫索引

在碼云建立一個私有庫索引,起名為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

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容