首先找一個可以創(chuàng)建私有倉庫的平臺,比如coding.net
首先創(chuàng)建一個遠程索引倉庫
創(chuàng)建好后添加到本地
可以在本地pod repo查看當前已有索引庫
pod repo add YJTestSpecs https://git.coding.net/zhangyjcoding/YJTestSpecs.git ? //添加到本地
成功的話,再次查看pod repo
索引庫創(chuàng)建好以后就可以創(chuàng)建你自己的私有倉庫了
現(xiàn)在托管平臺創(chuàng)建一個空的倉庫,然后在本地創(chuàng)建一個pod模版工程
pod lib create YJTestPod
rm -r ReplaceMe.swift //刪除無用代碼
touch test.swift ?//添加自己的代碼
cd ..
cd..
cd Example
pod install
重新pod成功后,修改對應(yīng)的podspec文件
vim YJTestPod.podspec
修改完之后,提交代碼到遠程
git add .
git commit -m 'xxx'
git remote add origin https://git.coding.net/zhangyjcoding/YJTestPod.git ?//關(guān)聯(lián)遠程地址
git push origin master
git tag '0.1.0' ?//添加標簽,要與podspec中一致
git push --tags
驗證podspec文件
pod spec lint
驗證通過后,提交spec到本地repo,會自動更新到遠程
pod repo push YJTestSpecs YJTestPod.podspec
完成之后就算創(chuàng)建成功了,在使用的時候要注意在Podfile文件中添加
source 'https://git.coding.net/zhangyjcoding/YJTestSpecs.git'
source [其他repo地址]
不添加source的話也可以這樣
pod 'YJTestPod', :git => 'https://git.coding.net/zhangyjcoding/YJTestPod.git'
pod 'QueryKit' , :subspecs => ['Attribute','QuerySet']
pod 'QueryKit/Attribute'
組件間的通訊:
方案一:將宿主工程當作中間件,各模塊暴露通訊需要的API
方案二:MGJRouter當作中間件,介于宿主工程和模塊之間的層,通過url注冊服務(wù),其它地方通過url獲取服務(wù)(可以github看怎么用,比較簡單),但是要注意url的維護
方案三:target-action,每個文件提供一個統(tǒng)一披露的接口文件,額外維護一個中間件的分類擴展,其它地方通過target-action的方案進行交互,其實就是使用運行時,調(diào)用performSelector