Mac M2 Ventura(13.3) 新机 安装Cocoapods

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.更新配置,并验证

source ~/.zshrc 
 
ruby -v

6.最后直接安装即可

gem install cocoapods

你可能感兴趣的:(iOS,macos,cocoapods,xcode,M2)