萬能解決方案之完全解決macOS cocoapods環境的全部問題

今天新蘋果機安裝cocoapods,安裝完之後發現怎麼pod search 都沒有用html

命令行提示:ios

swhcxp@iosdevmac ~ % pod search Almofire                            

Setup completed

[!] Unable to find a pod with name, author, summary, or description matching `Almofire`

 

而後我重裝homebrew , RVM, Ruby,Cocoapods,都安裝到最新仍是沒用git

Homebrew官網安裝github

命令行輸入json

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

若是raw.githubsercontent.com訪問不了,在/private/etc/Hosts文件中添加:199.232.4.133 raw.githubusercontent.comruby

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1	localhost
255.255.255.255	broadcasthost
::1             localhost
0.0.0.0	account.jetbrains.com
199.232.4.133 raw.githubusercontent.com

 

或者使用國內鏡像安裝bash

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)" 

若是失敗多試幾回,多是你的網絡問題,安裝完成之後命令行輸入:brew -v ,查看homebrew版本看看是否安裝成功。網絡

 

RVM安裝curl

1.命令行輸入命令:oop

$ curl -L https://get.rvm.io | bash -s stable

2.載入RVM環境

$source ~/.rvm/scripts/rvm

3.查看安裝結果版本

$ rvm -v

  

使用RVM環境安裝Ruby

1.列出已知版本

$ rvm list known

2.安裝指定ruby版本

$ rvm install 2.3.0

3.查看ruby安裝狀態和版本

$ ruby -v

 

完全卸載舊Cocoapods

卸載老版本cocopods

$ sudo gem uninstall cocoapods

  

2.查看本地安裝過的cocopods相關東西

$ gem list --local | grep cocoapods

顯示以下:

cocoapods (1.0.1)

cocoapods-core (1.0.1)

cocoapods-deintegrate (1.0.1)

cocoapods-downloader (1.1.1)

cocoapods-plugins (1.0.0)

cocoapods-search (1.0.0)

cocoapods-stats (1.0.0)

cocoapods-trunk (1.0.0)

cocoapods-try (1.1.0)

而後使用命令逐個刪除

$ sudo gem uninstall cocoapods-core

$ sudo gem uninstall cocoapods-deintegrate

  

Cocoapods安裝

升級gem

sudo gem update --system

 

更換鏡像源

$ gem sources --remove  https://rubygems.org/
 $ gem sources -a https://gems.ruby-china.com
 $ gem sources -l

 

安裝

OS X 10.11以前系統的安裝cocoapods 指令:

$ sudo gem install cocoapods

OS X 10.11之後系統的安裝cocoapods 指令,可安裝制定版本:

$ sudo gem install -n /usr/local/bin cocoapods
$ sudo gem install -n /usr/local/bin cocoapods -v 1.9.2

提示安裝完成後,查看一下pod版本

pod --version

  

嘗試刪除~/Library/Caches/CocoaPods/search_index.json從新pod search仍是不起做用

 

最後解決方案:

來源:http://www.javashuo.com/article/p-kolmswnx-ko.html 

pod repo remove master

cd ~/.cocoapods/repos

git clone --depth 1 https://github.com/CocoaPods/Specs.git master

rm ~/Library/Caches/CocoaPods/search_index.json

pod search afnetworking

  

問題彙總:

[!] CDN: trunk - Cannot perform full-text search because Algolia returned an error: 0: Cannot reach any host: execution expired, execution expired, 
SSL_connect returned=1 errno=0 state=error: certificate verify failed (unable to get local issuer certificate), execution expired  

解決方式:保證Podfile文件頭:source ‘https://github.com/CocoaPods/Specs.git‘, 而後執行:pod repo remove trunk , 再從新pod seach XXX,就能夠了!

相關文章
相關標籤/搜索