How to add new iPhone target

The Crazy Chimp picture The Crazy Chimp · Oct 21, 2011 · Viewed 8.4k times · Source

I'm trying to add a new target to my Xcode project so that I can run the same app, but with subtle difference.

Please can someone guide me through the setup of a new target since it is my first time and I'm not sure how to go about doing it.

In particular, I'm interested how I make the new target run the code in the original app. When I tried creating a new target it just made a new app delegate, and viewController file.

Sorry if this is simple, I'm just quite confused.

EDIT: Please note that I'm after after instructions based in Xcode 4.

Answer

Wolfert picture Wolfert · Oct 21, 2011

In xcode 4, make sure you're in the folder view where you have the project. Select the blue project button, then next to that you can see Targets, Select the target you have there, right click & select duplicate target.

Now you have two build targets.

To apply subtle differences in your app, make a global C flag. in Build settings there is a paragraph named GCC 4.2 - Language, it has a property named Other C Flags. Add your flag here like so:

-DOTHER_VER

Now in your code you can check for this using:

#ifdef OTHER_VER
    // some code.
#else
    // the subtle difference.
#endif