Pose you’re working on an application that is divided in multiple Xcode projects. These setups are quite common in cross platform development, where you often have one project for each logical part of the application. Let’s assume that we’ve got the following parts:

  • Foundation(.xcodeproj)
    A simple library with OS dependent implementations of threads, file system manipulation functions etc. Each class here inherits from an OS independent interface.
  • Controller(.xcodeproj)
    The heart of the application. This consists of OS independent logic that connects the different parts of the application
  • Interface(.xcodeproj)
    The interface that communicates with the controller

Let’s assume that you want each of these projects to treat all warnings as errors. How do you go about to perform that? One way would be to open up each project in Xcode and open up the project info window for the project in question. Then, under the Build tab, you’d scroll down to GCC 4.X - Warnings and enable Treat Warnings as Errors. That’s nice! Now all warnings are treated as errors - definitely worth a minute or two!

Now, when building one of the targets in the Foundation project, you notice that you do indeed still get warnings, even though you told the Xcode project that you wanted to treat each warning as an error. Huh? How come? You start scratching your head, once again re-opening the project info window to make sure that you really enabled the setting. And aaaah! You notice that, under the Build tab, the Configuration setting isn’t set to All Configurations but rather to Debug. Flipping it over to All Configurations you notice that the setting in question differs between the various configurations in the project; the Release configuration still isn’t set to Treat Warnings as Errors. Fixing it, and everything once again works as you intended it to do.

Now, that took quite some time to get right, didn’t it? And it was kind of error prone too, right? Wouldn’t it be so much simpler if you could make these kind of settings in one place instead? Well, there is; enter the wonderful world of the xcconfig (Xcode Configuration Settings File) file format. Want to see how it can be used? Take a look at the Xcode User Guide: Build Configuration Files and start enjoy your life as a Mac developer again… :)