views:

34

answers:

2

I want to make paid and free versions of my app. I want to structure things so that I can build one version or the other with as few changes as possible. As far as the source code is concerned, this is easily accomplished by having a BOOL constant isFreeVersion somewhere, and referring to it as needed.

But how should I set everything else up? Obviously the App ID will have to change, and this will in turn entail changing some build settings in XCode. What is the best way to keep that to a minimum?

+1  A: 

In term of version control in general, I wouldn't recommend using branches unless the impact of building two versions means important code changes between the two set of sources.

If you can have only one set of sources (with your BOOL constants), that means the rest must be managed through building script, which would:

  • take a parameter to know if it has to build the free version or the paid version of the executable (no parameter means it builds both)
  • use one XCode build setting or another, depending on the version it has to build.
VonC
+1  A: 

You could use a preprocessor flag (in your Xcode build settings) to switch between the two. The flag can be used across your source code using simple preprocessor directives (e.g. #if IS_FREE_VERSION ... #endif) in a manner similar to an if statement. This will help you avoid build scripts.

The disadvantage of this approach is that by default each time you build, the last build product gets overwritten.

Nick Toumpelis