1,安装brew
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
2,安装RVM(Ruby Version Manager)
curl -sSL https://get.rvm.io | bash -s stable
3,安装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[.8]
[ruby-]2.4[.10]
[ruby-]2.5[.8]
[ruby-]2.6[.6]
[ruby-]2.7[.2]
[ruby-]3[.0.0]
ruby-head
上面显示的最新版本是ruby-3.0.0,但是截止到标题日期最新版是3.4.5 稳定版,下面安装会使用3.4.5进行示例(最新版可能会有一些兼容问题,例如一些插件并没有支持到最新版导致不能正常使用,这个遇到问题了再说吧)
rvm install 3.4.5
或
rvm install ruby-3.4.5
设置Ruby默认版本
rvm use ruby-3.4.5 --default
4,更新Gem和更换源
sudo gem update --system
///这一步建议是先执行后续用到了再添加
///例如,你使用Fastlane进行自动化部署这个是需要的
gem sources --remove https://rubygems.org/
gem sources --add https://gems.ruby-china.com/
验证
gem sources -l
*** CURRENT SOURCES ***
https://gems.ruby-china.com/
注意:我的报,貌似没目录 不知道为什么
peng@MacBookPro ~ % gem source -l
*** NO CONFIGURED SOURCES, DEFAULT SOURCES LISTED BELOW ***
https://rubygems.org/
5,安装CocoaPods
sudo gem install -n /usr/local/bin cocoapods