views:

593

answers:

7

I would like to provide two different versions of my iPhone app on the App Store -- one free that is limited by the number of items displayed through the application, and another one completely unlimited.

The source code for both apps will be exactly the same, the only difference would be the SQLite database that stores the items in the app.

I understand that both versions of the app will need to have different bundle names, and different icons. I'm trying to find a way to avoid completely copying the source code directory to be able to customize some of these things: database, icons, nib strings, etc.

Is there a good way to do this without duplicating everything?

A: 

Create a new project, then have it reference (not create a local copy) of the same source files as the original project.

Lokkju
A: 

Is there a certain (iPhone-specific?) reason that you need to have different SQLite databases for both versions of your app?

If not, you could implement a licensing mechanism with exchangeable keys that allowed you to compile your single codebases with just one file changed. At runtime, your app would check that file and either allow reduced or unlimited storage. Added benefit (if iPhone-store supports such things) would be that it should be very simple to unlock the full version without losing data.

Of course, such a solution could harm your business if your customers are tech-savvy and malign and your code is easy to decompile.

Urs Reupke
+12  A: 

Just create a second target in your project. One can be the full featured application, which includes the full database, and the new target will be your demo build, with the demo database. We do this with Crosswords, and it works fine. You can then keep all your source in one place, and not worry about things getting out of sync.

Ben Gottlieb
Ben, I will play around with that idea. How about the issue of having different strings in some of the Nib files?
jpm
You can do that with either different xib files, or, as a commenter below notes, using #ifdef statements. We have a different pch header for each target, and have a bunch of #defines in there to control demo status.
Ben Gottlieb
+1  A: 

It is also worth noting that if a user decides to upgrade to the full version, if you do not have some mechanism in place to transfer over the existing data you will likely see a negative reaction from your users. If the contents of the data are small and can be mostly represented by text, I would suggest implementing a URL scheme for passing it over.

wisequark
Without using a web service to relay the data, there's no way for iPhone apps to share data with each other, so an auto-import-from-demo option isn't possible.
Marco
+7  A: 

Make judicious use of conditional compilation. I don't know what language you are working in, but in C/C++ conditionals compilation is done using the macro preprocessor and ifdefs. You would write code something like:

#ifdef FULL_APP
  // unlimited size
  #define SIZE -1
#else
  #define SIZE 100
#endif

When you build the program you supply the appopriate macro definitions on the compiler command line.

gcc program.cc -o program.o -DFULL_APP

You can use conditional compilation and the macro preprocessor in a variety of ways to turn on or off various features in the executable or modify other aspects of your program.

mxg
A: 

I have explored this and it seems that doing a "download a trial and upgrade it through the web" violates the terms of the app store. It seem you will really need two separate versions of the app in the store. (referencing back to Ben Gottlieb's entry). So one source, two distros.

Chris Slee
A: 

Conditional compilation is the best approach...

jm04469