尝试了多种方案,最终解决我问题的是按照以下步骤解决的,简单来说就是把ruby设置成2.7.3。
- install rbenv
brew install rbenv
echo 'eval "$(rbenv init -)"' >> ~/.zshrc
source ~/.zshrc
- install and switch to ruby
2.7.3
rbenv install 2.7.3
rbenv global 2.7.3
- make sure
ruby -vwas saying 2.7.3 - install cocoapods and cocoapods-keys, not through sudo, not with homebrew.
gem install cocoapods cocoapods-keys - install pod packages
pod install
常见问题:
1、如果在执行 brew install rbenv 命令时遇到如果报 Installing rbenv dependency: m4 fatal: not in a git directory.
可以设置为中科大的源
git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
brew update
安装成功的截图
参考链接: