I've heard rumors that it is possible to build different variations of an app without duplicating Xcode projects, by using targets and conditional compilation instructions like
IF !FREE_VERSION
[self loadGreatFeature];
ELSE
[self loadBoringFeature];
So:
How to set Xcode 4 up to be able to distinguish between building / archiving a free or paid version of the project?
How to tell Xcode 4 to include a certain set of images and other resources in the paid version, but not in the free version (and vice versa)?
How to tell Xcode 4 to build the free OR paid version? (don't want to build both of them all the time as this would slow development down)
What are the caveats of this approach?
I do know what's the caveat of duplicating the Xcode project: Once I fix a bug in either version, I must do the same thing in the other. Same goes for making improvements and modifications.
Open your project in Xcode and select the top-level item in the Project Navigator. You should see the list of targets for your project.
Create a new target for the free version of your app. An easy way to do this is to control-click a current target that's similar to what you want and duplicate it.
Select your new target. In the Build Phases tab you can control which source files will be built as part of this target and which resources are copied for it. In the Build Settings tab search for Preprocessor Macros and add a new one, for example MYAPPLITE=1, for all build configurations. You can then do conditional compilation in your code with something like:
#ifdef MYAPPLITE
[self loadBoringFeature];
#else
[self loadGreatFeature];
#endif
Finally, select Edit Scheme... from the Product menu. A new scheme should already have been created for your new target. You can rename it in the Manage Schemes sheet if you want. You can control specific settings for building, running, archiving etc. the new target here.
To switch between building the free version or the paid version you just change the active scheme.
The only real caveat is that you need to keep the settings for your new target up to date.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With