How do I manage building a Lite vs Paid version of an iPhone app?

Original answer is from the days before in app purchase. The correct answer now is to ship a single binary and offer your paid version through in app upgrades. It’s slightly more code but it’s a single shipment and your conversion rate will probably be better.

However, if you still want to versions of your app:

Xcode has good support for multiple targets.

From the project menu select “New Target…”. Add another iPhone executable (Cocoa Touch Application) you can then specify on a resouce by resource basis which items are included in your target. This can include only compiling certain code into your paid version.

You can get quick visual feedback on what is and is not included in the current target by right clicking on the “Groups and Files” list header (top lhs) and enabling Target Membership.

You switch between building different targets in the same way as you switch between building for Simulator or iPhone.

To specify at build time how a specific class behaves you can do two things – include two versions of the class which are each built for their respective target or, you can set a build time flag for the pre-processor. Select the Target in the “Groups and Files” list then “get info” on that target. Go to the build tab and search for “preprocess”. You should see a n item called “Preprocessor Macros” add LITE to your lite target and in the same way add PAID to your paid target.

Thein in your source files you can determine at compile time which version you are compiling for using #ifdef LITE etc.

Going even further, you could set a global flag or AppDelegate member variable based on #ifdef LITE and change behaviour at runtime for the Lite and paid apps. I’m not sure I see value in that though.

Leave a Comment