【问题标题】:Unable to install cocoapods无法安装 cocoapods
【发布时间】:2021-03-24 12:22:53
【问题描述】:

您好,我正在学习 React Native,我能够成功构建 Android 版本,但在 iOS 版本中我遇到了很多问题。我正在开发适用于 Android 和 iOS 的 Podcast 应用程序,但是当我尝试在我的应用程序中安装 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/json-2.3.1/ext/json/ext/generator
/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 ./siteconf20201214-42573-vm30sv.rb extconf.rb
creating Makefile

current directory: /Library/Ruby/Gems/2.6.0/gems/json-2.3.1/ext/json/ext/generator
make "DESTDIR=" clean

current directory: /Library/Ruby/Gems/2.6.0/gems/json-2.3.1/ext/json/ext/generator
make "DESTDIR="
compiling generator.c
In file included from generator.c:1:
In file included from ./../fbuffer/fbuffer.h:5:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby.h:33:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/ruby.h:24:10: fatal error: 'ruby/config.h' file not found
#include "ruby/config.h"
         ^~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/ruby.h:24:10: note: did not find header 'config.h' in framework 'ruby' (loaded from '/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks')
1 error generated.
make: *** [generator.o] Error 1

make failed, exit code 2

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

硬件:Mac Mini

谁能帮我解决这个问题。我想用sudo gem install cocoapods而不是brew安装它

【问题讨论】:

  • 您不必使用brew 来安装cocoapods,但是您必须说sudo 的事实是一种不好的气味。您需要立即控制您的 ruby​​ 并停止使用系统 ruby​​。你应该安装rbenv 并给自己一个个人红宝石。请参阅biteinteractive.com/how-to-get-started-with-pods - 如果您真的讨厌自制软件,您不必完全按照我所说的去做,但如果您确实按照我所说的去做,您将能够让 cocoapods 工作。

标签: ios ruby xcode react-native cocoapods


【解决方案1】:

您不应该使用 Apple 的 Ruby 安装。该安装供 Apple 内部使用。

由于您在问题中已指定要使用 Apple 的 Ruby 安装,因此恐怕无法解决此问题。

另一方面,如果您愿意使用不同的 Ruby installation(已安装 by handHomebrewruby-installruby-buildRVMasdf ,或任何其他方式),那么问题不应该首先出现。

有关详细信息,请参阅示例

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-04
    • 2016-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多