3

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?

6 Answers 6

13

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.

2
  • Ben, I will play around with that idea. How about the issue of having different strings in some of the Nib files?
    – jpm
    Nov 8, 2008 at 15:28
  • 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. Nov 8, 2008 at 20:05
7

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.

1

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.

1
  • 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
    Apr 23, 2009 at 12:22
0

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

0

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.

-2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.