Xcode stops working after set "xcode-select -switch"

Chris Chen picture Chris Chen · Mar 7, 2012 · Viewed 113.9k times · Source

OMG, what I've done?

Couple of days ago, I tried using macport to install something, because I'm using Xcode 4.3 and the command-line tool hadn't been installed by the time, macport wouldn't work. So I followed some guide to get command-line tool installed, then I used following command:

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

which I think screwed everything except macport: now, in Xcode, even a simple single-view iOS project won't be compiled, it says "UIKit/UIKit.h not found".

Does anyone know how to correct this? I don't want to re-install the gigantic Xcode again, gotta do some iOS project tonight, help!

Answer

Jim picture Jim · Mar 7, 2012

You should be pointing it towards the Developer directory, not the Xcode application bundle. Run this:

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

With recent versions of Xcode, you can go to XcodePreferences…Locations and pick one of the options for Command Line Tools to set the location.