在macOS Big Sur上安装CocoaPods出现错误

8

我正在配置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

这是因为分区名称中包含空格吗?我用于安装操作系统的驱动器名称为“macOS Big Sur”,而Flutter位于另一个名为“macOS Storage”的分区中。

有人能帮忙吗?


1
我使用@Alsh编译器在这里解决了这个问题:https://dev59.com/QFIG5IYBdhLWcg3wnC2l - Ashar
2个回答

15
这将通过以下方式解决:
sudo gem install -n /usr/local/bin cocoapods -v 1.8.4

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

sudo gem install -n /usr/local/bin cocoapods -v 1.8.4 对我有效。"brew install cocopods" 不再需要。 - Eray Hamurlu

4

我在BigSur下遇到了相同的错误,当我试图以传统方式安装cocoa时,发现了一件奇怪的事情。由于https://cocoapods.org地址出现了“内部服务器错误”,这意味着cocoa服务器出现了故障。因此,我计划使用home-brew安装新版本的cocoa。

我使用上述代码将home-brew安装到Mac中。

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

接着,我使用下面的命令卸载当前旧版的CocoaPods:

sudo gem uninstall cocoapods 

然后,我使用 Homebrew 安装了新版本的 CocoaPods。

brew install cocoapods  

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

brew link --overwrite cocoapods

获得胜利了 :)


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接