Unable to get MacPort functionality after installing Xcode 4.3

Jason picture Jason · Feb 17, 2012 · Viewed 57k times · Source

I am having trouble getting MacPorts to function properly. I just installed OSX Lion 10.7.3 I downloaded and installed MacPorts first, and then after reading the requirements, I downloaded Xcode4.3 from the App Store, and then installed it. I launched Xcode and it looks to be operational and functional. However when I attempted to port with MacPorts, it gave me this error message(excerpt):

Warning: xcodebuild exists but failed to execute
Warning: Xcode does not appear to be installed; most ports will likely fail to build.

I followed the advice from:

How do i install additional packages for Xcode on OSX Lion to allow MacPorts to work

and installed command_line_tools_for_xcode from the Preferences within Xcode. I closed Xcode, and again got the errors:

$ sudo port install libsocketsPassword:
Warning: xcodebuild exists but failed to execute
Warning: Xcode does not appear to be installed; most ports will likely fail to build.
--->  Computing dependencies for libsockets
--->  Dependencies to be installed: openssl zlib
--->  Extracting zlib
Error: Couldn't determine your Xcode version (from '/usr/bin/xcodebuild -version').
Error: 
Error: If you have not installed Xcode, install it now; see:
Error: http://guide.macports.org/chunked/installing.xcode.html
Error: 
Error: Target org.macports.extract returned: unable to find Xcode
Error: Failed to install zlib
Log for zlib is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_zlib/zlib/main.log
Error: The following dependencies were not installed: openssl zlib
Error: Status 1 encountered during processing.

I am uncertain where to go next with this. How do i trouble shoot my Xcode and MacPort interface?

Answer

geowar picture geowar · Feb 23, 2012

In theory this should work if you have Xcode4.3 installed (in /Applications):

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

(And you've installed the optional command line tools)