我正在尝试在全新的 Mac OS X 11.1 上安装 cocoapods。我已经运行了这些命令:
sudo gem install cocoapods -n /usr/local/bin
但是,当我运行最后一个命令时,出现此错误:
ERROR: Error installing cocoapods:
ERROR: Failed to build gem native extension.
current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /Library/Ruby/Site/2.6.0 -r ./siteconf20201226-10485-158gl5m.rb extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/include/ruby.h
You might have to install separate package for the ruby development
environment, ruby-dev or ruby-devel for example.
extconf failed, exit code 1
Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-20/2.6.0/ffi-1.14.2/gem_make.out
我该怎么做?
答案 0 :(得分:4)
sudo gem update --system
xcode-select --install
sudo gem install compass -n /usr/local/bin
sudo gem install cocoapods -n /usr/local/bin
解决了我的问题
答案 1 :(得分:0)
这里提出的解决方案都不适合我,我的解决方案是将 ruby 更新到这个版本:
rvm install ruby-2.6.3
rvm use ruby-2.6.3
rvm --default use 2.6.3
然后运行:
sudo gem install cocoapods