此處省略一萬字……
廢話不多說,直接進入正題扒接!
一、創(chuàng)建私有的spec文件倉庫
1.首先在github或gitlab上創(chuàng)建一個空項目,這里起名為DFSpecs.
2.在終端執(zhí)行如下命令:
pod repo add DFSpecs https://github.com/dzwing/DFSpecs.git
注釋:pod repo add 私有庫名字 github/gitlab 項目地址
作用:(1)創(chuàng)建本地倉庫 (2)同第一步創(chuàng)建的項目關(guān)聯(lián)起來
注意點: DFSpecs 是一個索引庫附迷,用來管理你的所有的私有pod 倉庫的podspec文件的惧互,執(zhí)行完上面第2步,會在~/.cocoapods/repos 目錄下自動生成DFSpecs 本地倉庫
二喇伯、創(chuàng)建我們需要pod的項目
1.另起一個路徑,執(zhí)行如下命令:
cd ~/Desktop/
//這個命令的作用是創(chuàng)建一個pod項目,它會自動給你生成spec文件
pod lib create DFCategoryKit
2.執(zhí)行完這個命令之后會有如下幾個選項,根據(jù)你的需求填寫就??了
3.選項填完之后回車,會自動創(chuàng)建一個項目,名稱就是DFCategoryKit
4.在DFCategoryKit里面有兩個文件夾
Assets:存放圖片資源等等
Classes:存放源碼,默認會有一個ReplaceMe.m文件
我們只需要把要上傳的代碼放入Classes文件即可,如果需要查看更改后demo效果,在Example中pod update即可更新修改的文件.
5.在github或gitlab上創(chuàng)建新的pod項目,這里我創(chuàng)建的地址是
https://github.com/dzwing/DFCategoryKit.git
6.進入DFCategoryKit項目,修改spec文件,這里可以用Sublime Text或者文件編輯器(不推薦,因為可能會改變"的格式,造成lint不通過),我這里直接在xcode中進行更改,根據(jù)你的需要進行相應(yīng)更改。
7.執(zhí)行pod lib lint --allow-warnings (--verbose加上顯示詳情)
-> DFCategoryKit (0.1.1)
DFCategoryKit passed validation.
終端如此顯示便是lint成功了.
8.繼續(xù)執(zhí)行如下命令:
git remote add origin https://github.com/dzwing/DFCategoryKit//這里是你需要pod的項目地址,不是私有庫的地址
git add .
git commit -m "注釋描述"
git push origin master
//注意:如果你創(chuàng)建項目的時候生成了README或者license文件,那么這里你push的時候可能會push不了,如是你可用
git push origin master -f 強制提交,會覆蓋之前的文件
9.為倉庫打tag稻据,這個tag需要和spec文件中的版本保持一致
git tag -m "你的描述" 0.1.1
git push --tags
10.最后的最后,我們渴望化成天使... 將你項目中的spec文件push到第一步創(chuàng)建的私有庫進行管理,可以用pod repo 命令查看你的私有庫
//執(zhí)行如下命令
// pod repo push 最開始建立的私有庫名稱 pod項目中的spec文件,--allow-warnings --verbose 忽略警告,打印詳細日志
pod repo push DFSpecs DFCategoryKit.podspec --allow-warnings
Validating spec --allow-warnings --verbose
-> DFCategoryKit (0.1.1)
Updating the `DFSpecs' repo
Your configuration specifies to merge with the ref 'refs/heads/master'
from the remote, but no such ref was fetched.
Adding the spec to the `DFSpecs' repo
- [Add] DFCategoryKit (0.1.1)
Pushing the `DFSpecs' repo
跟我一起倒數(shù)五個數(shù)艾猜,5捻悯、4算柳、3姓言、2囱淋、1,??到此私有庫就創(chuàng)建成功了唠倦,你可以去使用了稠鼻,具體怎么使用在這里就不做詳細敘述了~
創(chuàng)建成功之后可能會出現(xiàn)search不到的情況熙暴,此時可刪除本地搜索索引周霉,然后再進行搜索
rm ~/Library/Caches/CocoaPods/search_index.json
pod search DFCategory