寫在前面
之前也有把庫上傳到githup,並支援pod,
最近更新了幾次最新的三方庫,總結記錄一下
複製程式碼
步驟1 建立pod配置檔案
cd 到你檔案的目錄下,執行 pod init (假設你已經安裝了pod,並且可以正常執行)
生成Podfile檔案, 我們需要對其進行相應的配置
配置的地方不多
複製程式碼
s.name = "DDGScreenShot" //專案名稱
s.version = "1.0.0" //專案版本
s.summary = "A short description of DDGScreenShot." //專案介紹
s.description = <<-DESC //專案詳細介紹(寫在兩DESC中間)
圖片生成工具,一句程式碼,即可生成圖片,並對圖片進行簡單修飾
DESC
s.homepage = "https://github.com/dudongge/DDGScreenShot/tree/master" //連結地址
s.license = "MIT" //開源協議
s.author = { "dudongge" => "532835032@qq.com" } //作者資訊
s.platform = :ios //平臺系統
s.platform = :ios, "9.0" //相容最低版本
s.source = { :git => "https://github.com/dudongge/DDGScreenShot.git", :tag => "1.0.0" } //資原始檔地址 這個版本號要和以前的一致
s.source_files = "DDGScreenShot/DDGScreenShot/", "Classes/**/*.{h,m}" //資原始檔
複製程式碼
2 把程式碼push 到pod 遠端庫
git tag 1.0.0 (新增tag)
git push --tags (推送tag到遠端)
git push origin master (推送到遠端到程式碼倉庫)
//若想修改
// 刪除本地tag
git tag -d 1.0.0
// 刪除遠端tag
git push origin -d tag 1.0.0
//再重新提交即可
pod spec lint DDGScreenShot.podspec
pod spec lint DDGScreenShot.podspec --allow-warnings (忽略警告)
pod trunk push DDGScreenShot.podspec
Updating spec repo `master`
CocoaPods 1.5.0.beta.1 is available.
To update use: `sudo gem install cocoapods --pre`
[!] This is a test version we'd love you to try.
For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.5.0.beta.1
Validating podspec
-> DDGScreenShot (1.0.2)
- WARN | summary: The summary is not meaningful.
- WARN | description: The description is shorter than the summary.
# 提交到 pod
pod trunk push DDGScreenShot.podspec
pod trunk push DDGScreenShot.podspec --allow-warnings
# 若是第一次提交 會提示你去註冊郵箱(已註冊過,可以忽略)
pod trunk register 郵箱地址 "使用者名稱" --description="macbook pro"
之後會有一封帶有驗證連結的郵件傳送到你輸入的郵箱,點選驗證後就可以回來終端繼續提交操作了。
#再次push 程式碼
pod trunk push DDGScreenShot.podspec
pod trunk push DDGScreenShot.podspec --allow-warnings
複製程式碼
3 提交成功和檢視
? Congrats
? DDGScreenShot (1.0.1) successfully published
? April 2nd, 18:55
? https://cocoapods.org/pods/DDGScreenShot
? Tell your friends!
pod setup成功後會生成~/Library/Caches/CocoaPods/search_index.json檔案。
終端輸入rm ~/Library/Caches/CocoaPods/search_index.json
刪除成功後再執行pod search DDGScreenShot
> DDGScreenShot (1.0.0)
A short description of DDGScreenShot.
pod 'DDGScreenShot', '~> 1.0.0'
- Homepage: https://github.com/dudongge/DDGScreenShot/tree/master
- Source: https://github.com/dudongge/DDGScreenShot.git
- Versions: 1.0.0 [master repo]
複製程式碼
更新自己已有的庫
時間久了,自己的庫的內容也要補充,當然,這就涉及到版本升級,
當然升級前有些準備工作,比如將最新的程式碼提交到github上,本文不涉及這方面內容,
會重新寫一篇文章(可以參考下Githud Desktop )桌面軟體,其實 so easy。
複製程式碼
**大致也分了幾個小步驟:**
s.version = "1.0.1"
s.source = { :git => "https://github.com/dudongge/DDGScreenShot.git", :tag => "1.0.1" }
git tag 1.0.1 (新增tag)
git push --tags (推送tag到遠端)
git push origin master (推送到遠端到程式碼倉庫)
pod trunk push DDGScreenShot.podspec
pod trunk push DDGScreenShot.podspec --allow-warnings
。。。。。。一段時間之後
-------------------------------------------------------------------------------
? Congrats
? DDGScreenShot (1.0.1) successfully published
? April 3nd, 13:55
? https://cocoapods.org/pods/DDGScreenShot
? Tell your friends!
那麼,就更新成功了
rm ~/Library/Caches/CocoaPods/search_index.json
pod search DDGScreenShot
-> DDGScreenShot (1.0.1)
A short description of DDGScreenShot.
pod 'DDGScreenShot', '~> 1.0.1'
- Homepage: https://github.com/dudongge/DDGScreenShot/tree/master
- Source: https://github.com/dudongge/DDGScreenShot.git
- Versions: 1.0.1, 1.0.0 [master repo]
...skipping...
大功告成!!!!!
複製程式碼