1,brew确认是否已安装homebrew
没安装:/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
(比homebrew官网命令的快)
序号随便选
等待下载完成
重启终端或运行source /Users/os/.zprofile(实际为/Users/本机名称/.zprofile),国内地址生效
再使用“brew”验证是否安装成功
2,which a ruby查询ruby是系统自带还是brew安装的
系统自带会输出/usr/bin/ruby(系统自带ruby版本2.6.0左右)
brew安装会输出usr/local/opt/ruby/bin/ruby
3,使用homebrew安装ruby最新版
brew install ruby
等待安装成功
根据提示执行echo 'export PATH="/opt/homebrew/opt/ruby/bin:$PATH"' >> ~/.zshrc
再执行source ~/.zshrc
ruby -v版本为3.3.1左右
4,安装pod,sudo gem install cocoapods,可能会报错:
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
Errno::ECONNRESET: Connection reset by peer - SSL_connect (Gem::RemoteFetcher::FetchError)
或者也显示成功
Successfully installed cocoapods-1.15.2
最终有xx gem installed结尾
但是执行pod命令还提示不存在
pod --version
zsh: command not found: pod
此时执行sudo gem install -n /usr/local/bin cocoapods重新安装,成功后
验证pod是否安装成功:pod --version
1.15.2
完成