无法安装cocoapods - 安装cocoapods时出错:错误:无法构建gem本机扩展

问题描述 投票:0回答:1

我正在尝试使用以下命令安装cocoapods:

sudo gem install cocoapods

我尝试过更新 ruby、卸载并重新安装 ruby,这样我就可以安装 cocoapods

这是我的错误:

Building native extensions. This could take a while...
ERROR:  Error installing cocoapods:
    ERROR: Failed to build gem native extension.

----More error response----

    current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.16.3/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 ./siteconf20231019-2526-1y2jjsl.rb extconf.rb
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.

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

  /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-21/2.6.0/ffi-1.16.3/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/ffi-1.16.3 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-21/2.6.0/ffi-1.16.3/gem_make.out
  1. sudo gem update —system
    我尝试运行这个来更新。
  2. xcode-select --install
    ,也尝试过这个,因为我看到有人说这对他们有用。这也行不通。

有人遇到过这个问题吗?你是如何解决的?

xcode rubygems cocoapods
1个回答
0
投票

更新 - 我如何解决这个问题:

  • mkmf.log
    中,您将找到您应该拥有的universal-darwinxx 文件。就我而言,是
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/universal-darwin21

  • 运行此命令

    cd $(xcode-select -p)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0
    以确认您当前拥有哪些文件。我发现我有
    universal-darwin22

  • 确认您有不同的文件后,运行此命令

    sudo ln -sf universal-darwin22 universal-darwin21
    。此命令创建一个名为
    universal-darwin21
    的符号链接,指向
    universal-darwin22

  • 这应该可以解决问题。现在,当您再次运行命令

    sudo gem install cocoapods
    时,您应该能够毫无问题地安装它

© www.soinside.com 2019 - 2024. All rights reserved.