views:

33

answers:

1

I am going to build a Mac application written in Obj-C with Xcode. For argument's sake let's say it will have 10 optional features. I need a way to enable or disable those features to create custom builds of the application. These builds would be automated (most likely through the Mac OS X Terminal) so I would need a way to state which of these features are enabled/disabled at build time (a configuration file or CLI arguments would be ideal.)

So what is the best way to accomplish this? I'm trying to plan this out before I start coding so that there is proper separation in my code base to allow for these features to come and go. Ideally the custom build would only contain compiled code for the features it should have. In other words I don't want to always compile all the features and condition them out at runtime.

+2  A: 

You can use Xcode configurations for this purpose; for each configuration you could include a different prefix header, for example. Then you can trigger builds form the command line via xcodebuild.

If you'd prefer the config file approach, you can use a .xcconfig file instead to define any of the Xcode build settings.

The Xcode Build System Guide describes both of these approaches.

Nicholas Riley
I don't think manually creating a configuration for each combination is very plausible: http://www.wolframalpha.com/input/?i=combinations+of+10I don't want to make 1,024 configs :-)But I'll look into the .xcconfig file idea. Thanks!
macinjosh