安装cocoapods报错ERROR: Error installing cocoapods:

报错

最新系统安装cocoapods报错

/local/bin cocoapods
Password:
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/universal-darwin19/rbconfig.rb:229: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
Building native extensions. This could take a while...
ERROR:  Error installing cocoapods:
    ERROR: Failed to build gem native extension.
       current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20201123-4548-32dfh3.rb extconf.rb
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/universal-darwin19/rbconfig.rb:229: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
checking for ffi.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.  

原因是因为

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/universal-darwin19/rbconfig.rb:找不到这个

检查一下本地的目录是

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/universal-darwin20/rbconfig.rb:

注意

    在找ruby-2.6.0的时候,因为每个人的ruby环境不一样所以要注意自己的目录是否是对的上我的是ruby 2.6.3,所以不建议直接复制目录cd进去,一步步找自己本地的文件

我的路径是

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0

解决方案

报错里提示universal-darwin19 本地的却是universal-darwin20
所以将20复制粘贴将universal-darwin20文件改成universal-darwin19


image.png

在 ruby-2.3.0 目录下创建一个 universal-darwin18
在console下:
cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-XXX⚠️
mkdir universal-darwinXX⚠️
cp -r ./universal-darwinXX⚠️/* ./universal-darwinXX⚠️/

⚠️根据本地的需要去修改

你可能感兴趣的:(安装cocoapods报错ERROR: Error installing cocoapods:)