安装 cocoapods 时出错

AiU*_*AiU 7 ruby gem cocoapods

这是错误:

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

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/include/ruby.h


Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/json-1.8.1 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
Run Code Online (Sandbox Code Playgroud)

我在谷歌上搜索了过去 7 个小时,但找不到适合我的解决方案。我都试过了

请帮帮我

编辑:*安装 RVM 后,我仍然收到相同的错误

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

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/include/ruby.h


Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/json-1.8.1 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
Run Code Online (Sandbox Code Playgroud)

使用此命令行: sudo gem install cocoapods

the*_*Man 1

您使用的是 Mac 操作系统。要得到:

\n\n
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb\nmkmf.rb can\'t find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/include/ruby.h\n
Run Code Online (Sandbox Code Playgroud)\n\n

你正在尝试将 gems 安装到你的系统 Ruby 中,这是由 Apple 安装的供它们使用。

\n\n

不要那样做。

\n\n

相反,使用rbenvRVM在单独的沙箱中管理/安装 Rubies,您可以在其中随意折叠/旋转/毁坏。

\n\n

如果您选择 RVM,请在开始之前*阅读完整的安装说明*。RVM 功能非常齐全且灵活,但安装时需要付出额外的“选项”(也称为“复杂性”)的代价。作为单用户执行此操作,永远不要使用sudo,你应该没问题。

\n\n

我们可以借助 Apple 系统安装的 Ruby,但不要修改它,除非您真正了解自己在做什么;上面的错误让我认为情况并非如此。

\n\n

要安装 Apple 预装的 Ruby 以外的 Ruby,您很可能需要当前的 Xcode 以及命令行扩展。这将提供编译本机扩展所需的工具,以及所需的所有标头:

\n\n\n