How to exclude a file from build in XCode 6.1.1

I primarily use Mac OS X for development. While there are virtually hundreds of different text editors and IDEs I somehow got used to XCode for all my C++ development tasks. I like XCode because it provides me good compiler and easy to use IDE with all the debugging tools I might need.

However, just recently I’ve needed to exclude one of the cpp files from my project and couldn’t find any “meaningful” option that would let me do that. Nothing like “Exclude this file from build” sort of thing from Visual Studio. Turns out I wasn’t looking at the right place.

I just needed “File Inspector” and there under “Target Membership” there is your current project, where you could simply uncheck the checkbox and the particular file won’t be included in the build.

Target Membership - Xcode File Properties

Target Membership – uncheck projects for which you don’t want particular file to be built

Also, the same thing could be achieved by going to Project Properties and then selecting Build Phases tab. There should be Compile Sources category where you can individually select which files should go in your build.

Build Phases - Xcode Project Properties

Just remove files you don’t want to be compiled from the “Compile Sources” list

That’s it, simple as that. Hope you find it useful.

Manca