CocoaPods卸載與安裝

卸載

1.卸載Cocoapods

sudo gem uninstall cocoapodsgit

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

gem list --local | grep cocoapodsgithub

顯示以下:api

cocoapods (1.0.1)xcode

cocoapods-core (1.0.1)ruby

cocoapods-deintegrate (1.0.1)bash

cocoapods-downloader (1.1.1)app

cocoapods-plugins (1.0.0)curl

cocoapods-search (1.0.0)工具

cocoapods-stats (1.0.0)ui

cocoapods-trunk (1.0.0)

cocoapods-try (1.1.0)

而後使用命令逐個刪除

sudo gem uninstall cocoapods-core

注:若是出現root用戶沒有/user/bin權限,那是因爲系統啓用了SIP(System Integerity Protection)致使root用戶也沒有修改權限,因此咱們須要屏蔽掉這個功能

1.重啓電腦

2.command + R 進入recover模式

3.點擊最上方菜單使用工具,選擇終端

4.運行命令csrutil disable

5.從新啓動電腦

安裝

1.查看當前Ruby版本

ruby -v

2.升級Ruby環境,首先須要安裝rvm

curl -L get.rvm.io | bash -s stable

source ~/.bashrc

source ~/.bash_profile

3.查看rvm版本

rvm -v

結果: rvm 1.29.9 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [rvm.io]

4.安裝rvm(版本能夠經過rvm list查看能夠安裝的rvm的版本)

rvm install 2.5.1

注: 若是沒有安裝homebrew可能會報錯

安裝homebrew:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

安裝homebrew的時候可能會出現這樣的錯誤:

報錯一: error: RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 60

fatal: the remote end hung up unexpectedly

fatal: early EOF

fatal: index-pack failed

Error: Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core failed!

Failed during: /usr/local/bin/brew update --force

這裏網上找了不少方法試了一下,最後,更換清華大學的homebrew的鏡像源:

git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git

git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git

git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git

brew update

報錯二: Error: Another active Homebrew update process is already in progress.

Please wait for it to finish or terminate it to continue.

解決方法:

rm -rf /usr/local/var/homebrew/locks

而後從新執行 rvm install 2.5.1

5.更換源

查看源是什麼 gem sources -l

gem sources --remove https://gems.ruby-china.org/

更換爲 gem sources --add https://gems.ruby-china.com/

注:若是安裝了多個Xcode使用下面的命令選擇

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

6.安裝cocoapod

sudo gem install -n /usr/local/bin cocoapods

7.安裝本地庫

pod setup

相關文章
相關標籤/搜索