1. GitHub上新增倉庫

如上圖,不用新增README也不用選擇.gitignore和license。
2. 開啟終端cd到準備好的資料夾下,建立本地倉庫
cd /Users/aq/Desktop/Pod
pod lib create GifLoadingView
複製程式碼

-
如圖所示,此時資料夾下已經建立了一個名為GifLoadingView-Object的本地庫了(由於前兩步忘記截圖後來補的,後面的操作倉庫名都為GifLoadingView)。
-
接下來會要求選擇平臺、語言、是否建立demo等,如下圖:

- 本地倉庫建立成功後,Xcode會自動開啟倉庫裡的demo。倉庫的檔案目錄如下:

以後pod安裝的檔案位置如下圖所示,將自己的檔案放到Classes資料夾下代替ReplaceMe.m。

3. 測試本地倉庫,修改podspec
- cd到Example資料夾下,pod install更新倉庫。安裝完畢Xcode中你的程式碼就會出現在Development Pods資料夾下,你可以修改程式碼並測試,確認無誤後進行下一步。

- 修改podspec

如上圖,重要的地方都有標註,圖中的3和4即第一步建立的倉庫的houmePage和source

4. 提交程式碼到遠端倉庫
前面的步驟都確認無誤後可以提交程式碼了。
- 首先提交程式碼到本地

git status
檢視狀態
git add .
git commit -m '描述xxxx'
提交到本地
- 關聯本地倉庫到遠端倉庫

新增關聯
git remote add origin https://github.com/onexf/GifLoadingView.git
檢視關聯
git remote
push到遠端倉庫
git push origin master
以前在終端沒有登入過GitHub賬號的話會要求你輸入使用者名稱和密碼,按提示操作就行。
複製程式碼
- 打標籤

檢視標籤
git tag
新增標籤
git tag '0.1.0'
這裡tag值'0.1.0'
要與前面podspec檔案中s.version
相同
將tag推送到遠端倉庫
git push --tags
5. 推送podspec到pod庫
lint檢查自己的倉庫

如圖,cd到倉庫根目錄
pod spec lint
複製程式碼
如果依賴了第三方庫則用下面的命令
pod spec lint --use-libraries
複製程式碼
最後一步
pod trunk push GifLoadingView.podspec
複製程式碼
同樣,如果依賴了第三方庫需要在末尾加上 --use-libraries
pod trunk push GifLoadingView.podspec --use-libraries
複製程式碼

然後就可以pod search GifLoadingView
搜尋到你的pod庫了。
如果報以下錯誤
[!] You need to register a session first.
使用下面的命令註冊一下
pod trunk register xxxxxx@qq.com 'namexxx' --description='desxxxxx'
複製程式碼
替換自己的郵箱,會收到一封郵件,開啟郵件裡的連結即可,開啟後如下圖:

這樣就可以回到上一步push你的庫了