制作自己的Pod庫

  1. 首先在github新建repo


    github.png
  2. clone倉庫至本地


    clone.png
  3. 初始化項目


    initial.png
  4. 創建podspec文件

pod spec create MBMediator https://github.com/MarioBiuuuu/MBMediator.git
podspec.png
  1. 配置podspec
Pod::Spec.new do |s|
  s.name         = "MBMediator"
  s.version      = "0.0.1"
  s.summary      = ""
  s.description  = <<-DESC
                   DESC
  s.homepage     = "https://github.com/MarioBiuuuu/MBMediator"
  s.license      = "MIT"
  s.author             = { "AuthorName" => "AuthorEmail" }
  s.platform     = :ios, "7.0"
  s.source       = { :git => "https://github.com/MarioBiuuuu/MBMediator.git", :tag => s.version}
  s.source_files  = "MBMediator", "MBMediator/**/*.{h,m}"
end

s.source_files = ' ' 的多種寫法

ss.source_files = 'MBMediator/Class/*.{h,m}'

表示MBMediator/Class/目錄下的所有 .h 和 .m 文件

s.source_files = 'MBMediator/**/ .'

/后面的 . 應是 星號,MarkDowm語法沖突在此不能正常顯示
表示MBMediator/ 目錄下所有文件,包括子目錄下所有文件。 **/.表示遞歸
當有多個文件時,應用,隔開

 s.source_files = 'MBMediator/Class.{h,m}', 'MBMediator/Util*'
  1. 給項目打tag,并push到遠程倉庫
git tag 0.0.1

push到遠程倉庫

git push origin --tags
  1. 驗證podspec是否正確
pod lib lint
liblint.png
  1. pod Trunk注冊
 pod trunk register email地址 'MBMediator'
trunk.png

根據提示前往郵箱確認,然后執行

pod trunk me
trunkme.png
  1. 上傳MBMediator.podspec 到 CocoaPods/repo
pod trunk push MBMediator.podspec
result.png
  1. 檢驗
pod search MBMediator
  1. 上傳成功后搜索不到自己的庫怎么辦?
[!] Unable to find a pod with name, author, summary, or descriptionmatching '······'

刪除~/Library/Caches/CocoaPods目錄下的search_index.json文件
由于pod setup成功后會生成~/Library/Caches/CocoaPods/search_index.json文件。
終端輸入rm ~/Library/Caches/CocoaPods/search_index.json
刪除成功后再執行pod search

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容