I do not want to maintain two sets of code. I just need to limit some features in the Lite version and add some advertisements on it.
How to do that?
Create multiple targets.
You can vary build configurations by right-clicking on a target and selecting Get Info. From there, you can do things like change which Info.plist
file it's looking at (to do things like add "Lite" to the name and change the icon/load images) and set compiler flags so that you can #ifdef
in places.
If there are lots of files that are only applicable in the full version, then you can right-click on them and remove them from the Lite target to make a smaller app.
I've experimented with various alternatives, such as multiple configurations, and I keep coming back to multiple targets. I usually have at least three defined - Development, Ad hoc and App Store, each with their own particular settings.
Add an additional target to your Xcode project by duplicating the existing one. Define a macro in the new target (under "preprocessor macros" in build settings), something like "macroIsFreeVersion"
Now you can do this:
#ifdef macroIsFreeVersion
// code that will only execute in the free version here
#endif
and this:
#ifndef macroIsFreeVersion
// code for only the paid version goes here
#endif
You will need to make additional changes for the bundle id, provisioning profile, etc. All the stuff you did to put your paid version into the store.