最近升级的mac os 12 在执行pod安装时,出现如下 错误:
Ignoring ffi-1.15.3 because its extensions are not built. Try: gem pristine ffi --version 1.15.3
/usr/local/Cellar/cocoapods/1.10.2/libexec/gems/cocoapods-1.10.2/lib/cocoapods/command.rb:128:in `git_version': Failed to extract git version from `git --version` ("xcrun: error: active developer path (\"/Applications/Xcode12.app/Contents/Developer\") does not exist\nUse `sudo xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools, or use `xcode-select --install` to install the standalone command line developer tools.\nSee `man xcode-select` for more details.\n") (RuntimeError)
...
于是在网上搜索相关的内容,各种折腾就是没好,最后是在stackoverflow
上找到的解决方法,供有相似情况的同学参考 https://stackoverflow.com/questions/20939568/error-error-installing-cocoapods-error-failed-to-build-gem-native-extension 。
这个贴子列出各种答案,我经过尝试,使用了下面的方法才解决。
xcode-select --reset
sudo xcode-select --switch /Library/Developer/CommandLineTools
sudo gem install -n /usr/local/bin cocoapods