4

I have been stuck on this issue for a couple hours now and I cannot find a solution. I am running Mavericks and have Xcode 5.0.2 installed (which comes with the Command Line Tools).

My environment:

  • using RVM with ruby version 1.9.3p484
  • Xcode 5.0.2
  • Mac OS 10.9.1
  • Gem 2.2.0
  • Bundler version 1.3.5

Sudo gem install cocoapods outputs

kyles-mbp-2:fresh-driver-ios kylechronis$ sudo gem install cocoapods
     Building native extensions.  This could take a while...
     ERROR:  Error installing cocoapods:
     ERROR: Failed to build gem native extension.

    /Users/kylechronis/.rvm/rubies/ruby-1.9.3-p484/bin/ruby -rubygems    
    /Users/kylechronis/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/gems/1.9.1/gems/rake- 0.9.2.2/bin/rake RUBYARCHDIR=/Users/kylechronis/.rvm/rubies/ruby-1.9.3- p484/lib/ruby/gems/1.9.1/extensions/x86_64-darwin-13/1.9.1/xcodeproj-0.14.1 RUBYLIBDIR=/Users/kylechronis/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/gems/1.9.1/extensions/x86_64-darwin-13/1.9.1/xcodeproj-0.14.1

   /Users/kylechronis/.rvm/rubies/ruby-1.9.3-p484/bin/ruby extconf.rb
   checking for -std=c99 option to compiler... yes
   checking for CoreFoundation... no
   checking for main() in -lCoreFoundation... no
   CoreFoundation is needed to build the Xcodeproj C extension.
    *** 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.

Is this an issue with CoreFoundation not being found? or using a different version of Ruby? Any help or input would be greatly appreciated.

Kyle C
  • 4,077
  • 2
  • 31
  • 34

4 Answers4

19

Installing new Ruby version helped me. Follow these steps

rvm reinstall ruby-2.0.0-p247 --with-gcc=clang --verify-downloads 1
gem install xcodeproj
gem install cocoapods

I found this answer in some old Github issue.

ortemij
  • 206
  • 1
  • 6
  • 1
    this was the fix for me, although I backdated myself from 1.9.3-p484 to 1.9.3-p448 . Seems like something is messed up with the p484 build in this scenario. – ether_joe Feb 24 '14 at 20:41
  • this fixed it for me too with xcode 5.0.2, it wasn't working with ruby 1.9.2-p442 – frank Feb 27 '14 at 02:42
  • Thank you! Worked perfectly! Spasibo Artem! – Denis Apr 17 '14 at 17:50
  • use `sudo gem install cocoapods` if you want to be able to use cocoapods from within *any* directory on your system.. the above command only makes it work on the same directory it was installed FYI, this is also in accordance with the installation [instructions](http://guides.cocoapods.org/using/getting-started.html) on the cocoapods website – abbood Apr 24 '14 at 10:10
  • Worked with 2.1.1 also – Echelon May 21 '14 at 10:18
2

I ran into this:

http://cocoafactory.com/blog/2013/02/01/troubleshooting-cocoapods-installation/

and this:

http://railsapps.github.io/installrubyonrails-mac.html

I kinda figured i needed to update something since I was in 1.9.3 i tried updating to 2.1.0. Then I realized I couldn't by doing rvm install ruby. So I did

sudo gem update --system

that did something which worked, then I was able to run

rvm install ruby which updated successfully to 2.1.0

Reinstalled cocoa pods btw...and now

pod setup has given me Setting up Cocoadpods master repo :)

marciokoko
  • 4,988
  • 8
  • 51
  • 91
0

http://railsapps.github.io/installrubyonrails-mac.html

and this :

rvm get stable --auto-dotfiles

did the trick

Stone Alessandro
  • 359
  • 3
  • 14
0

i had the identical error messages and spent a lot of time trying all the various answers above and on other sites and other SO pages including:

ERROR: Error installing cocoapods: ERROR: Failed to build gem native extension

and

http://www.relaxdiego.com/2012/02/using-gcc-when-xcode-43-is-installed.html

and many others

none of it made any difference

i ultimately created a new user on my iMac to see if i could install cocoapods successfully on a pristine install, and it worked beautifully. i checked all the various versions of everything (ruby, gcc) and found they were the same for the new user as for my old user.

then i realized there were some extra lines added in my ~/.bashrc and ~/.bash_profile files that were there to help set up virtualenv as follows:

in .bashrc:

export WORKON_HOME=$HOME/.virtualenvs 
export PROJECT_HOME=$HOME/Desktop/Programming
source /usr/local/bin/virtualenvwrapper.sh

and in .bash_profile:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" 

after commenting these lines out and sourcing .bashrc and .bash_profile

$ source ~/.bashrc
$ source ~/.bash_profile

then

$ sudo gem install cocoapods 

worked flawlessly...

hope this helps someone else in my previously hopeless situation

Community
  • 1
  • 1
dave adelson
  • 853
  • 9
  • 15