如何在macOS Mojave 10.14.2版上安装CocoaPods?

问题描述

我正在尝试在macOS Mojave版本10.14.2上安装CocoaPods,但收到以下错误报告。该问题可能有什么解决方案?

提前谢谢

亲切的问候

Last login: Sun Aug 16 16:21:38 on ttys000
d-i89-230-83:~ mymac$ sudo gem install cocoapods
Password:
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.3.0/gems/ffi-1.13.1/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20200816-2278-1pv037b.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... no
checking for ffi_prep_closure_loc() in -llibffi... no
checking for ffi_prep_closure_loc() in -llibffi-8... no
creating extconf.h
creating Makefile

To see why this extension Failed to compile,please check the mkmf.log which can be found here:

  /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-18/2.3.0/ffi-1.13.1/mkmf.log

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

current directory: /Library/Ruby/Gems/2.3.0/gems/ffi-1.13.1/ext/ffi_c
make "DESTDIR="
Configuring libffi
mkdir: /tmp: No such file or directory
mkdir: /tmp: No such file or directory
config.guess: cannot create a temporary directory in /tmp
configure: error: cannot guess build type; you must specify one
make: *** ["/Library/Ruby/Gems/2.3.0/gems/ffi-1.13.1/ext/ffi_c/libffi-universal-darwin18"/.libs/libffi_convenience.a] Error 1

make Failed,exit code 2

Gem files will remain installed in /Library/Ruby/Gems/2.3.0/gems/ffi-1.13.1 for inspection.
Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-18/2.3.0/ffi-1.13.1/gem_make.out
d-i89-230-83:~ mymac$ 

解决方法

从输出中,我看到您缺少构建gem所需的一些C库。 首先安装libffi,然后重试。

您可以使用Brew

brew install libffi