在 macOS Big Sur 上安装 cocoa pods 时出错

Error installing cocoa pods on macOS Big Sur

我正在我的机器上设置 flutter。但是,当我尝试使用

安装 cocoapods 时
sudo gem install cocoapods

我收到这个错误:

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.15.0/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 ./siteconf20210324-1667-1wwdce5.rb extconf.rb
checking for ffi.h... no
checking for ffi.h in /usr/local/include,/usr/include/ffi,/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/ffi,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/ffi... yes
checking for ffi_prep_closure_loc() in -lffi... yes
checking for ffi_prep_cif_var()... yes
checking for ffi_raw_call()... yes
checking for ffi_prep_raw_closure()... yes
creating extconf.h
creating Makefile

current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.0/ext/ffi_c
make "DESTDIR=" clean

current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.0/ext/ffi_c
make "DESTDIR="
make: *** No rule to make target `"/Volumes/macOS', needed by `AbstractMemory.o'.  Stop.

make failed, exit code 2

Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.0 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-20/2.6.0/ffi-1.15.0/gem_make.out

是否是分区名称中包含'space'造成的?我安装 OS 的驱动器名称是 'macOS Big Sur' 而 flutter 驻留在另一个分区上 'macOS Storage'

有人可以帮忙吗?

这将通过以下方式解决:

sudo gem install -n /usr/local/bin cocoapods -v 1.8.4

如果您需要安装 CocoaPods 1.10.0 +,您可以使用 HomeBrew 并在命令行中使用以下命令:

brew install cocoapods

我在BigSur下遇到了同样的错误, 当我尝试以传统方式安装 cocoa 时,我发现了一件奇怪的事情。 https://cocoapods.org 地址出现“内部服务器错误”。这意味着 cocoa 服务器出现问题。所以我计划使用自制软件安装新版本的 cocoa。

我使用上面的代码将 home-brew 安装到 Mac。

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

然后,我卸载了当前的旧版本cocoapods,使用下面的命令

sudo gem uninstall cocoapods 

然后,我安装了新版本的 cocoa pods 使用自制程序,

brew install cocoapods  

然后,我使用下面的命令来修复不一致。

brew link --overwrite cocoapods

胜利:)