在Apple M1 Pro 安装cocoapods报 Failed to build gem native extension,ffi-1.15.5解决方案

511 阅读1分钟

尝试了多种方案,最终解决我问题的是按照以下步骤解决的,简单来说就是把ruby设置成2.7.3。

  1. install rbenv
brew install rbenv
echo 'eval "$(rbenv init -)"' >> ~/.zshrc
source ~/.zshrc
  1. install and switch to ruby 2.7.3
rbenv install 2.7.3
rbenv global 2.7.3
  1. make sure ruby -v was saying 2.7.3
  2. install cocoapods and cocoapods-keys, not through sudo, not with homebrew.
    gem install cocoapods cocoapods-keys
  3. install pod packages
    pod install

常见问题:

1、如果在执行 brew install rbenv 命令时遇到如果报 Installing rbenv dependency: m4 fatal: not in a git directory.

Screen Shot 2022-11-20 at 21.47.33.png 可以设置为中科大的源

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

安装成功的截图

Screen Shot 2022-11-20 at 21.45.28.png

Screen Shot 2022-11-20 at 21.45.46.png

参考链接:

1、Error loading plugin on M1 mac

2、 Mac安装Homebrew