cocoapod添加倉庫

1、提交代碼到github

1)在github添加遠(yuǎn)程倉庫
2)將本地代碼提交到遠(yuǎn)程倉庫
git remote add origin 遠(yuǎn)程倉庫地址
git pull origin master --allow-unrelated-histories
git branch --set-upstream-to=origin/master master
git add .
git commit -m "添加本地代碼到遠(yuǎn)程倉庫"
git push
3)設(shè)置倉庫的版本(打tag必須設(shè)置版本,后面會(huì)用到)
git tag -m "首次提交" "1.0"
git push --tags

git add .
git commit -m "first commit"
git remote add origin https://github.com/tiancanfei/ADDeviceTool.git
git push -u origin master

可能出的錯(cuò)誤及解決辦法:
fatal: refusing to merge unrelated histories
git pull origin master --allow-unrelated-histories
//git pull和git fetch的不同
http://blog.csdn.net/wfdtxz/article/details/8632811

2、構(gòu)建podspec文件

1)創(chuàng)建.podspec文件
touch 項(xiàng)目名稱.podspec
2)編輯.podspec文件


Pod::Spec.new do |s|

  s.name         = "倉庫名稱"
  s.version      = "版本號(hào)"
  s.summary      = "概述"

  s.description  = <<-DESC
                   詳細(xì)描述 
                   DESC

  s.homepage     = "github倉庫網(wǎng)址(區(qū)別倉庫地址https://github.com/*****/*****)"

  s.license      = "MIT"
  s.license      = { :type => "MIT", :file => "LICENSE" }

  s.author             = { "作者名稱" => "郵箱地址" }

  #支持平臺(tái)
  s.platform     = :ios
  #支持平臺(tái)版本,如果是swift版本必須是>8.0的
  s.platform     = :ios, "7.0"
  #倉庫地址 (不要使用ssh)
  s.source       = { :git => "https://github.com/*****/****.git", :tag => "#{s.version}" }

  #源文件位置
  s.source_files  = "ADCarouselView/ADCarouselView/*.{h,m}"
  # s.exclude_files = "Classes/Exclude"

  #倉庫地址 (暴露出來的頭文件,如果是swift就不需要這行,swift沒有頭文件)
  s.public_header_files = "ADCarouselView/ADCarouselView/*.h"

  #需要的framewoke
  # s.framework  = "UIKit"
  s.frameworks = "UIKit"

  #庫
  # s.library   = "iconv"
  # s.libraries = "iconv", "xml2"

 #是否arc
  s.requires_arc = true

  # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }

 #需要依賴的三方
 #s.dependency 'SDWebImage', '~> 3.7.6'

end

3)驗(yàn)證.podspec文件(輸出倉庫passed validation表明成功,不能又任何警告錯(cuò)誤,否則可能無法成功添加倉庫)
pod lib lint --allow-warnings --use-libraries

3、trunk檢測(這里使用trunk方式添加倉庫)

pod trunk me如果能輸出你的賬號(hào)信息即可
如果出現(xiàn)
Authentication token is invalid or unverified. Either verify it with the email that was sent or register a new session.
那么注冊一下
pod trunk register 郵箱地址 "作者名稱"(這里的郵箱可以隨便填,163好像收不到郵件)

4、提交代碼到cocoapod倉庫

提交到cocoapod倉庫了
pod trunk push *.podspec --allow-warnings --use-libraries

提交成功顯示如下

??  Congrats

 ??  倉庫名稱 (版本號(hào)) successfully published
 ??  February 7th, 21:33
 ??  https://cocoapods.org/pods/倉庫名稱
 ??  Tell your friends!

提交成功后可以在
https://github.com/CocoaPods/Specs/tree/master/Specs
查看到剛剛提交的記錄

在幾個(gè)小時(shí)以后可以嘗試在
https://cocoapods.org/
搜索要是能搜到那么倉庫已經(jīng)審核成功了
此時(shí)就可以直接像使用其他三方庫一樣使用podfile來添加模塊(但此時(shí)我在terminal搜索到我們的庫,查看了下https://github.com/CocoaPods/Specs/tree/master/Specs
的提交歷史,好像得三天以后才可以搜索到)

如果仍然pod serach不到嘗試

1、pod setup更新倉庫
2、刪除搜索記錄
rm /Users/targetcloud/Library/Caches/CocoaPods/search_index.json`后再搜索
3、重新搜索
5、更新cocoapod倉庫

1)先打tag,并提交到github

2)修改*. podspec文件中的version版本號(hào)

3)重新push
pod trunk push *.podspec 即可(版本相同push將會(huì)失敗)

6、xcode8錯(cuò)誤

- ERROR | [iOS] unknown: Encountered an unknown error (Simulator iPhone 4s is not available.) during validation
直接更新cocoapod即可

sudo gem install -n /usr/local/bin cocoapods
7、使用static libriaries錯(cuò)誤(--use-libraries)
ERROR | [iOS] Encountered an unknown error (The 'Pods' target 
has transitive dependencies that include static binaries: (......) 
during validation.

8、使用依賴,請使用import <>
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容