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)行使用了
