記錄一下安裝cocoapods失敗的問題。
新電腦,好久沒用cocoapods了,新用到了一個庫需要裝一下cocoapods,結(jié)果
sudo gem install cocoapods
的時候報錯了,錯誤就是標(biāo)題那樣的:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby.h:33:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/ruby.h:24:10: fatal error: 'ruby/config.h' file not found
OK,既然問題來了,那就search吧,在這里找到了答案:

image.png
也就是用xcrun工具安裝:
xcrun gem install cocoapods,原因截圖里也說明了。但是直接這么run有可能會報這個錯:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.
所以加上sudo就行:sudo xcrun gem install cocoapods
總結(jié)
搜索大法好!