利用CocoaPods創(chuàng)建私有庫(kù)

1. 在gitLab創(chuàng)建JSKlineChart

2.clone遠(yuǎn)程到本地

cd /Users/ahs

git clone ?http://code.aihuishou.com/zhuwenqi/JSKlineChart.git

3.查看當(dāng)前有哪些本地索引倉(cāng)庫(kù)

cd ~

cd .cocopods

open repos

4.創(chuàng)建本地索引庫(kù)并和遠(yuǎn)程索引庫(kù)做關(guān)聯(lián)?

pod repo add?JSKlineChart??http://code.aihuishou.com/zhuwenqi/JSKlineChart.git

5.再次查看repos,會(huì)發(fā)現(xiàn)多了一個(gè)索引

6.在桌面隨便建一個(gè)Test文件夾,創(chuàng)建本地代碼組件模版庫(kù)

cd /Users/ahs/Desktop/Test

pod lib create?JSKlineChart

7.回答問題

iOS -> Swift

你會(huì)發(fā)現(xiàn)自動(dòng)生成了一個(gè)項(xiàng)目,如下:


上圖中可以看到,里面有一個(gè)Example文件夾,可以刪了

8. 刪除索引庫(kù)?JSKlineChart->JSKlineChart->Classes->ReplaceMe.m

9.編輯JSKlineChart.podspec文件,需要修改的有:

(1)a.summary 隨便寫個(gè)備注

(2)s.homePage 換成你的遠(yuǎn)程索引庫(kù)地址?http://code.aihuishou.com/zhuwenqi/JSKlineChart

? ? s.source: git =>?http://code.aihuishou.com/zhuwenqi/JSKlineChart.git

10.把Test/JSKlineChart文件夾下面的除去.git文件夾外的所有文件拷貝到/Users/ahs/JSKlineChart,提交到遠(yuǎn)程代碼并打tag

cd /Users/ahs/JSKlineChart

git add .

git commit -m "initPod"

git remote add origin?http://code.aihuishou.com/zhuwenqi/JSKlineChart.git

git push origin master (push之后刷新下遠(yuǎn)程倉(cāng)庫(kù)地址,看代碼有沒有成功推送到遠(yuǎn)程)

git tag "0.1.0"

git tag (查看版本號(hào)是否提交成功)

git push --tags

注意: 一定要提交tag。不然會(huì)報(bào)"warning: Could not find remote branch 0.1.0 to clone.fatal:Remote branch 0.1.0 not found in upstream origin"的錯(cuò)誤。這里就是把整個(gè)所有的文件提交到了遠(yuǎn)程倉(cāng)庫(kù)

11.通過pod spec lint --allow-warnings命令驗(yàn)證podspec索引文件(注: pod lib line是檢索本地索引文件,pod spec lint是本地和遠(yuǎn)程庫(kù)同時(shí)檢索)

這里先執(zhí)行個(gè)echo "4.1" >> swift_versions?

驗(yàn)證通過結(jié)果如下:

-> JSKlineChart(0.1.0)Analyzed 1 podspec.JSKlineChart.podspec passed validation.

12.驗(yàn)證通過后,pod repo push <本地索引庫(kù)> <索引文件名> --allow-warnings 提交索引文件到遠(yuǎn)程索引庫(kù)。注意cd到正確的push路徑

pod repo push JSKlineChart JSKlineChart.podspec --allow-warings

正確輸出如下:

Validating spec->JSKlineChart(0.1.0)Updating the `JSKlineChart' repoFrom https://github.com/zzyyd6316/JSKlineChart*[new branch]master->origin/master*[new tag]0.1.0->0.1.0Adding the spec to the `JSKlineChart' repo-[Update]JSKlineChart(0.1.0)Pushing the `JSKlineChart' repoTo https://github.com/zzyyd6316/JSKlineChart.git 8306a85..58890d7 master->master

13.over,在本地產(chǎn)看已成功



1. 現(xiàn)在我們新建一個(gè)項(xiàng)目MyPodTest導(dǎo)入庫(kù)試試

cd /Users/ahs/Desktop/MyPodTest

pod init

2. 編輯podfile文件為

?platform:ios,'9.0'

target'MyPodTest'dopod'JSKlineChart',:git=>'http://code.aihuishou.com/zhuwenqi/JSKlineChart.git',:tag=>'0.1.0'

end

3.執(zhí)行pod install,你會(huì)發(fā)現(xiàn)JSKlineChart已經(jīng)導(dǎo)入了你的項(xiàng)目里面



4.現(xiàn)在就可以導(dǎo)入頭文件進(jìn)行使用了


?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容