我试图将cocoapods安装到运行OSX 10.9.1(新Mavericks)的MacBook Pro上,键入gem install cocoapods后,我得到以下错误:

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

        "/usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby" -rubygems /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rake-10.1.1/bin/rake RUBYARCHDIR=/Users/rangreenberg/gems/gems/xcodeproj-0.14.1/ext RUBYLIBDIR=/Users/rangreenberg/gems/gems/xcodeproj-0.14.1/ext
/usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
checking for -std=c99 option to compiler... *** 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.

Provided configuration options:
    --with-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby
/usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:491:in `block in try_compile'
    from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:443:in `with_werror'
    from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:491:in `try_compile'
    from extconf.rb:24:in `block in <main>'
    from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
    from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
    from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
    from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
    from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
    from extconf.rb:23:in `<main>'
rake aborted!
Command failed with status (1): [/usr/local/rvm/rubies/ruby-1.9.3-p194/bin/...]

Tasks: TOP => default => ext
(See full trace by running task with --trace)


Gem files will remain installed in /Users/rangreenberg/gems/gems/xcodeproj-0.14.1 for inspection.
Results logged to /Users/rangreenberg/gems/gems/xcodeproj-0.14.1/ext/xcodeproj/gem_make.out

当前回答

如果以上方法都不起作用,那么按照以下步骤进行

sudo xcode-select——switch /Library/Developer/CommandLineTools Sudo gem安装cocoapods

如果你得到这样的错误 '

ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /usr/bin directory

.'

执行步骤3

$ sudo gem install -n /usr/local/bin cocoapods . sh

其他回答

如果你没有Homebrew,请先安装:https://brew.sh/index_pt-br

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

其次,如果你没有ruby,安装它: https://www.ruby-lang.org/pt/documentation/installation/

brew install ruby

你也可以按照这些步骤:https://gist.github.com/monicao/d372716cdfbb7e9cf692

然后,关闭终端,重新打开。

始终使用sudo安装cocoapods:

sudo gem install cocoapods

你需要安装Xcode的开发工具。最简单的方法是通过终端(这个问题)

xcode-select --install

我的解决方法:

首先,我有新的mac os 10.15.7和Xcode

以前的解决方案对我也没用

我注意到pods安装在库2.6.0,并决定它需要更新:

步骤1

\curl -sSL https://get.rvm.io | bash -s stable --ruby

Ok!

然后我检查了版本:2.6.0 -为什么? 在安装ruby后的最后一个字符串中,我注意到:

要开始使用RVM,您需要运行source /Users/abazhanov/.rvm/scripts/ RVM 在所有打开的shell窗口中,在极少数情况下需要重新打开所有shell窗口。

好吧,我们开始吧:

步骤2

source /Users/abazhanov/.rvm/scripts/rvm

然后我检查了版本:2.7.0 -它是好的!

步骤3

sudo gem install cocoapods 

结果是:安装了34个宝石

我知道新版本的Pods根本没有安装在旧版本的Ruby上

以前的解决方案对我都没用。

我的情况是一个新的干净安装的macOS Catalina + XCODE;

碰巧在安装可可豆之前,我必须首先运行Xcode(在第一次运行中,Xcode设置机器与工具);

在那之后,可可豆荚就正常了。

这应该不浅桶和核心回购。

brew tap homebrew/cask

其次是…

brew tap homebrew/core