I want to release two versions, of my iOS App on the AppStore.
One is paid and other is free. As of now my code is finished for the paid App. Now I want to add more code for iAd and InAppPurchase's for the free app.
What is the best approach for maintaining the two versions? I was thinking about copying the Xcode Project or creating a branch in my git repo.
If you branch or copy the project you're creating a maintenance nightmare for yourself down the road.
Create a separate target in the same project, specific differences can be handled via #ifdef blocks in the code. Add defines to each target to specify whether you're building paid or free versions.
== ADDED ==
To define the per target symbols go to build setting for the target, scroll way down until you find the Apple LLVM 5.1 - Preprocessing block, the change the target-specific settings to add your desired symbol (FREE_BUILD=1 or PAID_BUILD=1 e.g.)
To add target specific code you can then use that defined symbol in your code as:
// some code here
#if FREE_BUILD
// Some code that only gets compiled for the free target here
#elif PAID_BUILD
// Some code that only gets compiled for the paid target here
#else
// Just in case because I'm a paranoid sob
#error Must define FREE_BUILD or PAID_BUILD
#endif
来源:https://stackoverflow.com/questions/22568483/best-practice-how-to-handle-code-differences-for-ios-app-when-creating-free-and