一凤巨、打造本地私有庫
- 創(chuàng)建一個(gè)localLib的文件夾,并且按照名字創(chuàng)建一個(gè)文件夾TZSoundBase1然后需要一個(gè)Classes文件夾對(duì)應(yīng)男摧,所有的源碼category都放在這里
步驟一
- 創(chuàng)建一個(gè)git代碼倉庫和一個(gè).spec文件蔬墩,并且注意homePage和source屬性的設(shè)置
$ cd /LocalLib/LRSoundBase1
$ git init
# 在 Classes 中添加源代碼
$ git add .
$ git commit --m '增加了分類'
$ pod spec create LRSoundBase1
LRSoundBase1.podspec
- 在項(xiàng)目中創(chuàng)建一個(gè)podfile文件導(dǎo)入我們創(chuàng)建好的本地私有庫,注意我們的文件路徑
$ cd /LRSound
$ pod init
# 編輯 podfile 文件
profile
4.使用pod install集成我們的組件到宿主工程中
$ pod install
本地私有庫導(dǎo)入成功
二耗拓、本地私有庫優(yōu)化的原因:
- 我們需要手動(dòng)創(chuàng)建git倉庫
- 需要手動(dòng)創(chuàng)建.spec文件
- 需要手動(dòng)創(chuàng)建測試工程
優(yōu)化的方案:使用pod的模板庫解決之
- 使用 pod 模板庫創(chuàng)建本地私有庫LRSoundBase1
$ cd /本地私有庫方案優(yōu)化/LocalLib
$ pod lib create LRSoundBase1 #使用 pod 模板庫創(chuàng)建本地私有庫LRSoundBase1
-
將框架源代碼放到 Classes 文件夾下面:
添加框架源代碼 - 安裝到測試工程
$ cd /本地私有庫方案優(yōu)化/LocalLib/LRSoundBase1/Example
$ pod install
- 編輯
LRSoundBase1.podspec
框架描述符文件
$ cd /本地私有庫方案優(yōu)化/LocalLib/LRSoundBase1
$ pod lib lint --allow-warnings #本地驗(yàn)證
- 新建項(xiàng)目進(jìn)行安裝測試
$ cd /本地私有庫方案優(yōu)化/LRSound
$ pod init
# 修改 Example文件夾的 PodFile 文件拇颅,同上面的 profile 圖;
$ pod install
三乔询、如何打造我們的遠(yuǎn)程私有索引庫
- 創(chuàng)建一個(gè)pod的模板庫
- 在遠(yuǎn)程創(chuàng)建一個(gè)私有遠(yuǎn)程代碼倉庫
- 將源碼上傳到遠(yuǎn)程代碼倉庫里
- 在本地添加一個(gè)私有索引庫
- 修改好.spec文件
- 將.spec文件上傳到本地索引庫樟插,本地索引庫會(huì)將.spec文件自動(dòng)上傳到遠(yuǎn)程私有索引庫
- 集成到宿主工程中
安裝第三方框架流程圖.png
打造遠(yuǎn)程私有索引庫思路.png
① 創(chuàng)建一個(gè)pod的模板庫
$ cd /遠(yuǎn)程私有庫方案/RemoteLib
$ pod lib create LRSoundBase2
② 添加框架源碼到 Classes 文件夾,編輯 LRSoundBase2.podspec
框架描述符文件
③ 將源碼上傳到遠(yuǎn)程代碼倉庫, 并且添加 tag
$ cd /遠(yuǎn)程私有庫方案/RemoteLib/LRSoundBase2
$ git add .
$ git commit --m '增加了基礎(chǔ)組件'
$ git remote add origin https://gitee.com/lrskey/LRSoundBase2.git #跟遠(yuǎn)程代碼倉庫建立連接
$ git remote #驗(yàn)證是否連接上
$ git push origin master # 推送到遠(yuǎn)程
$ git tag '0.1.0' #添加 tag
$ git push --tags # 推送到遠(yuǎn)程
$ pod lib lint --allow-warnings #本地驗(yàn)證
$ pod spec lint --allow-warnings #遠(yuǎn)程驗(yàn)證
# 本地驗(yàn)證和遠(yuǎn)程驗(yàn)證必須先做竿刁,出錯(cuò)了可以及時(shí)修改
④ 克隆遠(yuǎn)程私有索引庫到本地
# LRSoundBase2:私有庫的名稱
# https://gitee.com/lrskey/LRSoundBase2.git 私有庫的地址
$ pod repo add LRSoundSpec2 https://gitee.com/lrskey/LRSoundSpec2.git
克隆遠(yuǎn)程私有索引庫到本地
⑤ 將.spec文件上傳到本地索引庫黄锤,本地索引庫會(huì)將.spec文件自動(dòng)上傳到遠(yuǎn)程私有索引庫
$ pod repo push LRSoundSpec2 LRSoundBase2.podspec
pod repo push LRSoundSpec2 LRSoundBase2.podspec
將.spec文件上傳到本地索引庫.png
自動(dòng)上傳到遠(yuǎn)程私有索引庫.png
⑥ 集成到宿主工程
$ pod repo #查看本地所有索引庫
$ pod install
注意: podfile 文件中需指明索引庫所在源地址
podfiel.png
⑦ 打造遠(yuǎn)程私有索引庫流程圖
打造遠(yuǎn)程私有索引庫流程圖