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

mmvthczy  于 2023-11-21  发布在  其他
关注(0)|答案(1)|浏览(121)

我正在特灵安装cocoapods是使用这个命令:sudo gem install cocoapods
我试过更新Ruby,卸载并重新安装Ruby,这样我就可以安装Cocoapods了。
下面是我的错误:

  1. Building native extensions. This could take a while...
  2. ERROR: Error installing cocoapods:
  3. ERROR: Failed to build gem native extension.
  4. ----More error response----
  5. current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.16.3/ext/ffi_c
  6. /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
  7. checking for ffi.h... *** extconf.rb failed ***
  8. Could not create Makefile due to some reason, probably lack of necessary
  9. libraries and/or headers. Check the mkmf.log file for more details. You may
  10. need configuration options.
  11. To see why this extension failed to compile, please check the mkmf.log which can be found here:
  12. /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-21/2.6.0/ffi-1.16.3/mkmf.log
  13. extconf failed, exit code 1
  14. Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/ffi-1.16.3 for inspection.
  15. 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,也试过这个,因为我看到有人说它对他们有效。这个也不起作用。
    任何人都面临这个问题,你是如何解决的?
3pvhb19x

3pvhb19x1#

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

  • mkmf.log中,您可以找到您应该拥有的universal-darwinxx文件。
  • 运行此命令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命令时,您应该能够安装它而不会出现问题

相关问题