由于重裝系統(tǒng)->so重裝cocoapods
一.鏡像安裝
1.之前淘寶的鏡像:https://ruby.taobao.org/ 已經(jīng)不能使用
2.網(wǎng)上很多說用:gem sources --add https://gems.ruby-china.org/ (結果終端提示找不到)
3.需要改為gem sources --add https://gems.ruby-china.com/
為了驗證你的Ruby鏡像是并且僅是ruby-china,執(zhí)行以下命令查看
gem sources -l
如果是以下結果說明正確
https://gems.ruby-china.com/
二.安裝方式(推薦按下面執(zhí)行,我2個都試了都沒報錯,報錯的話嚴格執(zhí)行)
Mac OS X 10.11前
sudo gem install cocoapods
Mac OS X 10.11后
sudo gem install -n /usr/local/bin cocoapods
三.找不到庫-本次討論的重點
這時候使用pod search AFNetworking是找不到庫的
錯誤大概是這樣的:
Unable to find a pod with name, author, summary, or description matching
AFNetworking
但是,在項目中創(chuàng)建podfile添加內容后,奇跡般的找到了庫
但是如果就這樣,終究是不妥的
platform :ios,'9.0'
use_frameworks!
target '你的app的名字' do
pod 'AFNetworking'
pod 'FMDB'
end
繼續(xù)尋求解決方案,之后看到下面操作
//我這里,現(xiàn)在是沒有這個文件的,具體去下面repos文件夾中看
mac@yshdeMacBook-Air ~ % pod repo remove master
//進入repos文件夾
mac@yshdeMacBook-Air ~ % cd ~/.cocoapods/repos
//如果沒有repos文件,則創(chuàng)建
mac@yshdeMacBook-Air ~ % mkdir -p ~/.cocoapods/repos/
創(chuàng)建完之后,注意查看文件,如果文件夾內有master文件夾, 執(zhí)行 pod repo remove master來刪除這個master文件
//然后克隆source源到一個新的 master 文件夾內
mac@yshdeMacBook-Air repos % git clone https://github.com/CocoaPods/Specs.git master
漫長的等待后,完成下載,然后刪除下面文件(原因忘記了,到底有么有也沒去查看,刪就是了)
rm ~/Library/Caches/CocoaPods/search_index.json
然后執(zhí)行:pod search AFNetworking 就沒問題了,
- 如果出現(xiàn)下面關于trunk的錯誤
1.CDN: trunk URL couldn't be downloaded:。。。。。。
2.CDN: trunk - Cannot perform full-text search。。。。。
執(zhí)行 pod repo remove trunk移除trunk源(現(xiàn)在我們用的master)
- 到了:pod install (沒記錯的話,我執(zhí)行后,repos文件夾里自動創(chuàng)建了這個trunk文件夾,想來大概是默認源)
You have either:
* out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
* mistyped the name or version.
* not added the source repo that hosts the Podspec to your Podfile.
emm。。我就再次給他刪除了,執(zhí)行pod repo remove trunk,并且在podfile中指定新源
platform :ios,'9.0'
source 'https://github.com/CocoaPods/Specs.git' (就是這一句)
use_frameworks!
target 'CodeReciew' do
pod 'AFNetworking'
pod 'FMDB'
end
之后大功告成,這個時候pod search AFNetworking 是沒有問題的, 為了檢驗(因為之前podfile中添加內容后,也是可以搜索到的),刪除podfile內容,pod search AFNetworking 依然沒錯,那就可以了
最后執(zhí)行 pod install 無誤,結束。。
————————————————
csdn搬遷,現(xiàn)在使用簡書了
原文鏈接:https://blog.csdn.net/ysh1251685564/article/details/106398786