1.执行命令:
sudo gem install cocoapods
因为是新机,内置的ruby版本是(2.6.0)太低,会报错
所以需要安装新的ruby版本
2.如果已经安装了低版本的homebrew,可以先卸载:
卸载:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
安装最新版本:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
因为是外网所以需要设置VPN,或者修改电脑配置 hosts文件,添加:
185.199.108.133 raw.githubusercontent.com
185.199.109.133 raw.githubusercontent.com
185.199.110.133 raw.githubusercontent.com
185.199.111.133 raw.githubusercontent.com
3.使用 homebrew 安装 最新版的ruby:
brew install chruby ruby-install
安装结束会提示:
- Run these two commands in your terminal to add Homebrew to your PATH:
(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/guojunlong/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
- Run brew help to get started
- Further documentation:
https://docs.brew.sh
此时按照提示依次执行:
(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/guojunlong/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
然后安装 ruby3.2.2
ruby-install ruby 3.2.2
4.配置环境:
echo "source $(brew --prefix)/opt/chruby/share/chruby/chruby.sh" >> ~/.zshrc
echo "source $(brew --prefix)/opt/chruby/share/chruby/auto.sh" >> ~/.zshrc
echo "chruby ruby-3.2.2" >> ~/.zshrc
5.更新配置,并验证文章来源:https://www.toymoban.com/news/detail-640748.html
source ~/.zshrc
ruby -v
6.最后直接安装即可文章来源地址https://www.toymoban.com/news/detail-640748.html
gem install cocoapods
到了这里,关于Mac M2 Ventura(13.3) 新机 安装Cocoapods的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!