views:

3397

answers:

7

Hi there;

I'm starting to get to the point where I want to consider building a lite version of my iPhone app. I've found a few things on the web that talk about the process a bit, namely:

http://developer.apple.com/tools/XCode/XCodeprojects.html

http://www.pacificspirit.com/blog/2009/01/27/building_for_multiple_iphone_targets_in_xcode

But I was wondering if anyone else knows of any links/resources they found good for understanding how to best manage this process? What I'm specifically interested in is simplifying the process of managing which files are included in the different versions of my app as I continually modify and enhance my paid for version.

Thanks,

Brad.

+31  A: 

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.

Roger Nolan
Vote up because it is a good technical answer, even if it competes with my philosophical one.
Paxic
Thanks for your answer Roger.... How does the "Product" concept work with the different targets? Or is it something completely different all together?
Brad Parks
producst are just executables Xcode builds for you. I'm suggesting setting up one product for your paid app and another for your lite app. They would each produce a different <productName>.app bundle to be uploaded to the app store.
Roger Nolan
Just a comment in case anyone comes along and reads this. In the current version of the iPhone SDK (2.2, xcode 3.1.2), the 'Preprocessor Macros' option has disappeared from the simulator, but it is still there on 'device' mode.
Chris Jefferson
+1  A: 

I used a git branch. I branched my main app and made a few tweaks to disable a bunch of content. Now i work mainly in the master branch and switch over to lite and merge in the latest when major developments occur. Works very well.

Squeegy
+6  A: 

As a developer you want to write the least code possible (less bugs, less time). As the build versions diverge you will have to invest more work and separate tests.

Unless you are making an expensive hacker tool you might consider keeping the difference as simple as possible - just have some hidden preferences or settings. This way the majority of checks and tests will do the same work in both builds, very little code will be different. The key concern is not to burden yourself as a developer.

The reason to have divergent builds is to ensure that the Free cannot be hacked into a "Paid" version. The people who would try and circumvent such a simple limitation are primarily a sub set of those who would jailbreak their phones. No matter what you do you will not get their money under any condition other than they are so wowed they buy it just to show appreciation.

Paxic
Voted up because it is a good philosophical even if it advises against using my technical solution ;-)
Roger Nolan
I completely agree, and I'm going to try and stay as close to my paid version as possible, without giving it all away!
Brad Parks
+2  A: 

Two more additional resources that I was directed to, outside of this group, are:

http://www.iphonedevsdk.com/forum/iphone-sdk-development/8036-lite-game-duplicate-xcode-project.html

and

http://www.mycodestudio.com/devnotes.html

Also, the creator of "Flower Garden" details the pros/cons of different approaches to creating a lite version here:

http://gamesfromwithin.com/from-full-to-lite-in-under-an-hour

Brad Parks
+1  A: 

I found success with:

Tutorial – Same Xcode Project Create Multiple Products for iPhone http://adeem.me/blog/2009/04/18/tutorial-same-xcode-project-create-multiple-products-for-iphone/

It covers much of what Roger Nolan mentioned in his answer to the question but step-by-step with screen shots.

It allows you to use C #ifdef's to include or exclude functionality in your app.

Some of the details were not exactly right -- because of differences in Xcode I'm sure -- but it wasn't too difficult to figure out the correct / new way to do each step.

NOTE: You'll have to go to Apple and get a new app ID for the Lite version of your app. The steps outlined in the tutorial will create a copy of the info.plist file, which you'll probably rename to something like infoLite.plist -- in this file you'll need to change the "Bundle Identifier" to match this new appID.

Mark Terry
+1  A: 

With iPhone 3.0, you can use in-app purchases instead and allow that to unlock the full functionality without having to make more than one app. I also think that this will avoid people getting this for free, but I'm not as sure about that.

nazgul42
+1  A: 

I agree with using Compiler flags, makes the code look clean and keeps everything simple. I wrote up a detailed tutorial with screen shots.

If you guys wanna check it out, its here...

How To: Create A Lite Version of Your iPhone App

Chris