RVM 安裝
-
打開終端:terminal
- 查看當(dāng)前Ruby版本
ruby -v
-
安裝rvm(第一步要下載一些東西等兩分鐘左右)
/* 如果之前安裝過秦躯,可以選擇升級最新版rvm get master */ curl -L get.rvm.io | bash -s stable source ~/.bashrc source ~/.bash_profile
如果出現(xiàn)以下情況:
curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused。
則我們需要配置代理裆装,先去https://www.ipaddress.com網(wǎng)站查找raw.githubusercontent.com的IP Address:199.232.96.133.
終端輸入以下指令sudo vi /etc/hosts
修改hosts
199.232.96.133 raw.githubusercontent.com
保存
如果出現(xiàn)以下情況:
則我們需要去設(shè)置--> 網(wǎng)絡(luò)--> 高級--> TCP/IP中把配置IPv6改成自動(dòng)踱承。ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
image.png保存,然后重新執(zhí)行curl -L get.rvm.io | bash -s stable命令
-
查看rvm版本
rvm -v
顯示如下(或者是其他版本):
rvm 1.29.3 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
Ruby 安裝
- 列出ruby可安裝的版本信息
顯示如下rvm list known
# MRI Rubies [ruby-]1.8.6[-p420] [ruby-]1.8.7[-head] # security released on head [ruby-]1.9.1[-p431] [ruby-]1.9.2[-p330] [ruby-]1.9.3[-p551] [ruby-]2.0.0[-p648] [ruby-]2.1[.10] [ruby-]2.2[.10] [ruby-]2.3[.7] [ruby-]2.4[.4] [ruby-]2.5[.1] ..... [ruby-]2.6[.3] // 重點(diǎn)在這里 重點(diǎn)在這里 重點(diǎn)在這里 [ruby-]2.7[.0-preview1] // 測試版 ruby-head .....
- 安裝一個(gè)ruby版本(這里我選擇的是2.6.3版本哨免,當(dāng)然你也可以選擇其他的)
// 注意:安裝過程中需要兩次按下 Enter 鍵, 第二次按下后需要輸入電腦訪問密碼(不可見,只管輸入就行); rvm install 2.6.3 //設(shè)置為默認(rèn)版本 rvm use 2.6.3 --default
Homebrew 安裝
- 檢查是否已安裝Homebrew
如果出現(xiàn)這種情況:zsh: command not found: brew茎活。則說明沒安裝Homebrew,則運(yùn)行以下命令行:brew doctor
或使用國內(nèi)鏡像:https://zhuanlan.zhihu.com/p/111014448/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Cocoapods 安裝
- 更換源(有代理铁瞒,可不更換)
sudo gem update --system gem sources --remove https://rubygems.org/ gem sources --add https://gems.ruby-china.com/ //為了驗(yàn)證你的Ruby鏡像是并且僅是ruby-china妙色,執(zhí)行以下命令查看 gem sources -l //如果是以下結(jié)果說明正確,如果有其他的請自行百度解決 *** CURRENT SOURCES *** https://gems.ruby-china.com/
- 開始安裝CocoaPods
sudo gem install -n /usr/local/bin cocoapods -v 指定版本 //如果安裝了多個(gè)Xcode使用下面的命令選擇(一般需要選擇最近的Xcode版本) sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
- 安裝本地庫
pod setup //執(zhí)行以上命令后 Setting up CocoaPods master repo $ /usr/bin/git clone https://github.com/CocoaPods/Specs.git master --progress Cloning into 'master'... remote: Counting objects: 1879515, done. remote: Compressing objects: 100% (321/321), done. Receiving objects: 21% (404525/1879515), 73.70 MiB | 22.00 KiB/ //然后就是漫長的等待慧耍,當(dāng)然,網(wǎng)絡(luò)好的情況下會(huì)更快
- 如果pod setup 沒反應(yīng)的解決方法:
進(jìn)入~/.cocoapods 文件夾身辨,刪除repos文件 執(zhí)行:新建repos文件夾 進(jìn)入repos文件夾: git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git master
徹底刪除CocoaPods的方法
第一步
#羅列依賴庫
$ gem list --local | grep cocoapods
第二步
#遍歷刪除依賴庫
$ for i in $( gem list --local --no-version | grep cocoapods );
do
sudo gem uninstall -n /usr/local/bin $I;
done
第三步
#進(jìn)一步徹底刪除文件夾
$ rm -rf ~/.cocoapods/
完整的三步操作實(shí)例如下
#羅列依賴庫
$ gem list --local | grep cocoapods
cocoapods (1.0.1)
cocoapods-core (1.0.1, 0.39.0)
cocoapods-deintegrate (1.0.0)
cocoapods-downloader (1.0.0, 0.9.3)
cocoapods-plugins (1.0.0, 0.4.2)
cocoapods-search (1.0.0, 0.1.0)
cocoapods-stats (1.0.0, 0.6.2)
cocoapods-trunk (1.0.0, 0.6.4)
cocoapods-try (1.0.0, 0.5.1)
#遍歷刪除依賴庫
$ for i in $(gem list --local --no-version | grep cocoapods);
do
sudo gem uninstall -n /usr/local/bin $I;
done
Password:
Remove executables:
pod, sandbox-pod
in addition to the gem? [Yn] y
等等
#進(jìn)一步徹底刪除文件夾
$ rm -rf ~/.cocoapods/