****遇到一個(gè)坑****,****之前電腦里裝有****cocoapods,****后來升級電腦到最新系統(tǒng)****,****可運(yùn)行到后面的時(shí)候發(fā)現(xiàn)提示我說****cocoapods****找不到了****,****如果你也有此情況****,****請看我的這篇文章
解決Mac OS X 10.11更新以后Cococapods找不到問題
升級10.11的系統(tǒng)以后執(zhí)行 pod install 的時(shí)候報(bào)錯(cuò)
-
一 在工程根目錄中初始化一個(gè)Podspec文件
Paste_Image.png 二 創(chuàng)建 podspec文件
pod spec create STRowLayout
之后會(huì)生成STRowLayout.podspec文件-
三 最好下載個(gè)Sublime程序(也可以是別的編輯器,可以百度自己找一下),專門用于編輯podspec(因?yàn)橹苯佑孟到y(tǒng)的編輯器打開被坑過,(????)??)
Paste_Image.png 四 用sublime編寫下面的代碼,注意要寫清楚,不然會(huì)報(bào)錯(cuò)
Pod::Spec.new do |s|
# 項(xiàng)目名稱
s.name = 'STRowLayout'
# 描述一下項(xiàng)目的作用
s.summary = 'On the basis of STRowLayout encapsulation.'
# 版本號
s.version = '1.0.1'
# 開源許可證
s.license = { :type => 'MIT', :file => 'LICENSE' }
# 作者信息
s.authors = { 'CoderST' => '694468528@qq.com' }
# 所支持的系統(tǒng)以及版本號
s.platform = :ios, '7.0'
# 項(xiàng)目首頁
s.homepage = "https://github.com/CoderST/RowFayout"
# 資源地址鏈接
s.source = { :git => 'https://github.com/CoderST/RowFayout.git', :tag => s.version.to_s }
# 是否支持arc
s.requires_arc = true
# 文件
s.source_files = 'STRowLayout/**/*.{h,m}'
# 頭文件
s.public_header_files = 'STRowLayout/*.{h}'
# 所用到的系統(tǒng)類庫
s.frameworks = 'Foundation', 'UIKit'
# 所用到 cocoapods 中的其他類庫
#s.dependency 'AFNetworking', '~>3.1.0'
end
注意:如果上面是swift的話要改為{swift}
s.source_files = 'STRowLayout/*/.{swift}'
- ERROR | name: The name of the spec should match the name of the file.
- ERROR | [iOS] file patterns: The `source_files` pattern did not match any file.
- 1 出現(xiàn)上面第一個(gè)錯(cuò)誤的時(shí)候,是因?yàn)閟.name 要寫成你上傳到cocoapods上文件的名稱,而不是你xcode新建項(xiàng)目的名稱
- 2 出現(xiàn)這個(gè)錯(cuò)誤就比較蛋疼了,在自己的房子了搞了一晚上都沒有搞好,第二天到公司,打開電腦,就在試了一下 "pod spec lint STRowLayout.podspec" 結(jié)果好了~~?? 也是醉了,懷疑更網(wǎng)絡(luò)有關(guān)系!
- 五 編寫后記得git一下
git add .
git commit -m"改動(dòng)的內(nèi)容"
git push
- 六 給項(xiàng)目打tag
git tag '1.0.1'
git push --tags
- 七 此部非常重要,如果錯(cuò)誤會(huì)報(bào)錯(cuò)誤(經(jīng)常會(huì)出現(xiàn)的錯(cuò)誤-第八步驟,出現(xiàn)錯(cuò)誤慢慢調(diào)),此處的STRowLayout.podspec改為你自己的podspec
pod spec lint STRowLayout.podspec
Paste_Image.png
看到上面的截圖,恭喜你,說明你已經(jīng)驗(yàn)證通過啦!!! - 八 報(bào)錯(cuò)信息
RowFayout git:(master) pod spec lint STRowLayout.podspec
-> STRowLayout (1.0.0)
- ERROR | file patterns: The `source_files` pattern did not match any file.
Analyzed 1 podspec.
[!] The spec did not pass validation, due to 1 error.
九 如果上面一部通過,恭喜你?? 已經(jīng)進(jìn)行一大半了,下面就是 - 注冊trunk
pod trunk register 694468528@qq.com 'CoderST' -- verbose
建議郵箱與Github的保持一致滋早,這樣提交日志上面就會(huì)顯示你的Github賬號十 查看自己注冊信息
pod trunk me
-
十一 提交
pod trunk push
有時(shí)可能會(huì)出現(xiàn)如下錯(cuò)誤:[!] There was an error pushing a new version to trunk: getaddrinfo: nodename nor servname provided, or not known
大體是因?yàn)榫W(wǎng)絡(luò)導(dǎo)致的缨硝,過一會(huì)兒再試試就行了(心中有一萬個(gè)草泥馬飛過~~)
Paste_Image.png
出現(xiàn)這個(gè)圖恭喜,你已經(jīng)上傳成功cocoapods -
十二 別慌恭喜和草泥馬,以為成功了 在pod search STRowLayout 出現(xiàn)下面錯(cuò)誤
Paste_Image.png
臥槽這成功更失敗有什么區(qū)別,既然說找不到!!!!
于是在找答案,可以用下面的命令試試
rm ~/Library/Caches/CocoaPods/search_index.json
Paste_Image.png
在pod search STRowLayout
Paste_Image.png
這下終于KO了~~??