The go-to fix for random build issues and bugs in Xcode is to delete the DerivedData directory. The shortcut for that is holding alt/option with the Product menu open: Clean Build Folder, or the keyboard shortcut ⌥⌘⇧K.

The venerable DerivedData directory is the Xcode equivalent of the build directory from your Makefile days. Except, by default it is not relative to your project source. Instead, it is in a unique (as in UUID) location under ~/Library/Developer/Xcode/.

I prefer a relative build directory because it’s closer to how you might be building your project from command line or CI scripts. Not having to divine where Xcode is keeping your object files is important for reasoning about how your code is (not) compiling.
And of course, it’s easier to blow it away with a quick rm!

So let’s change that default and take our build back.

Open up Xcode’s preferences window from the menu-bar, and change to the Locations tab. Change the Derived Data location to Relative as shown: Xcode Preferences Window Locations

Under the Advanced settings you can change the Build directory. Be warned, if you change this Xcode will no longer Clean Build Folder for you with the keyboard shortcut ⌥⌘⇧K.


1- keyboard shortcut ⌥⌘⇧K ( Option Cmd Shift K )


Some great feedback came through from Twitter.

First I want to clarify. The only reason I recommend this configuration is for when problems aren’t being fixed by a Command-Shift-K Clean in Xcode.

Unit Tests not being recognised. Interface Builder Designables not building. Headers not being found.
Usually you can fix it with a clean, building for test, refreshing all views, or restarting Xcode. But sometimes it just won’t give — and I’m not the only one.

Your milage may vary.

Then a tweet happened

@tonyarnold and @mokagio kicked off a discussion, pulling in @joar_at_work