Using MacPorts with Xcode 4.3.x


If you recently updated to the MacAppStore distribution of Xcode, you certainly noticed that the /Developer directory is not used anymore.  Xcode now lives in standard /Applications directory.

This confuses tools relying on Xcode, such as some MacPorts package relying on Xcode to compile code on your machine before installation.

For example :

---> Fetching archive for zlib
---> Attempting to fetch zlib-1.2.6_0.darwin_11.x86_64.tbz2 from http://packages.macports.org/zlib
---> Fetching zlib
---> Attempting to fetch zlib-1.2.6.tar.bz2 from http://lil.fr.distfiles.macports.org/zlib
---> Verifying checksum(s) for zlib
---> Extracting zlib
Error: Couldn't determine your Xcode version (from '/usr/bin/xcodebuild -version').

(more line stripped for clarity)

This can be solved with a single command line terminal, to tell Xcode command line tools the new location of Xcode.

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer/

I am still unsure this an Apple bug or a MacPort bug … I am keen to read your opinion about this.

Enjoy !

 

, ,

  1. #1 by anon on 22/03/2012 - 14:16

    +1, this worked for me on 10.7 lion with both xcode 3.2.6 and xcode 4.3.2… macports wouldn’t upgrade:

    Error: The installed version of Xcode (3.2.6) is too old to use on the installed OS version. Version 4.1 or later is recommended on Mac OS X 10.7.
    Error: Problem while installing pkgconfig
    To report a bug, see

  2. #2 by Alessandro on 27/03/2012 - 22:04

    Thanks a lot, it worked for me!

  3. #3 by Jan on 16/04/2012 - 20:47

    Hi! Thank you very much, it works like a charm. Only one question: is it safe to delete the old /Developer directory?

  4. #4 by sst on 17/04/2012 - 00:27

    I think so. I did it on my machine and so far everything is OK.
    The whole content is duplicated under /Applications/Xcode.app

  5. #5 by Jim Sifferle on 17/04/2012 - 06:44

    Thanks!! This solved my problem and was the only thing that I could find offering a fix.

  6. #6 by Chris Brown on 30/04/2012 - 23:19

    Not just a MacPorts fix — homebrew’s `brew doctor` will check this setting and recommend setting it (as above) if it’s not correct.

  7. #7 by Eli on 29/05/2012 - 17:09

    Thanks a ton! Was tearing out hair trying to figure this out, considering I’d already uninstalled earlier versions of XCode before upgrading…

  8. #8 by healwhans on 31/05/2012 - 02:51

    Thanks bro! This fixed it.

    I was also hoping to find a way to migrate Xcode 3 projects to Xcode 4 without too much pain. That will have to be another google search.

    Thanks again for posting the fix for MacPorts.

  9. #9 by Osserpse on 16/06/2012 - 21:46

    Thank you very much, works fine!

    It also solve a problem I had while installing Rails. I got this error:

    mkmf.rb can’t find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h

    But after your fix I can execute “sudo gem install rails” without problem.

    Again, thanks a lot!

  10. #10 by 123 on 26/07/2012 - 12:27

    Thanks a lot . This helps me a lot!

(will not be published)