Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

wlh99

macrumors 6502
Original poster
Feb 7, 2008
272
0
I would like to have 2 versions of my app, with more features for the pay version, and ads in the free version.

I'd like to use build configurations for it. In one version I need a settings bundle, the other not. I also need to know have to have blocks of code conditionally compile based on the selected configuration.

Is there documentation the demonstrates this? It seems like it would be a pretty normal thing.
 
if you want to use the same project code for paid and free versions for you app, you can change the Bundle Display Name in the info.plist for each version:

Code:
NSString *displayName = [NSString stringWithFormat:[[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString*)kCFBundleExecutableKey]];

if ([displayName isEqualToString:@"My App Paid"])
     NSLog(@"this is a paid app");

if ([displayName isEqualToString:@"My App Free"])
     NSLog(@"this is a free app");

if you only want the paid version to include a bundle.settings i think you'll have to drop it in your paid app version or remove it from the free app version. if the settings.bundle is present, i don't think it's possible to have it not load if the app is a free app, since it will be in your resources folder and will be apart of the build. but i could be wrong.

[EDIT] actually, that should be
Code:
NSString *displayName = [NSString stringWithFormat:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]];
 
You should really read the Xcode Build guide to get some ideas on this.

I haven't done this but I would probably build two targets in the project. Duplicate your first one. Then Have two pch files. Set your project defines there to differentiate between free/paid. Any project file can be added to one or both targets. You can have two files of the same name that reside in different directories if you want. You should be able to build two similar products in this way without too much effort. You can even set up a build configuration that will build both of them at once.
 
I also need to know have to have blocks of code conditionally compile based on the selected configuration.

Any good C text should cover this.

Code:
#define kPaidVersion

#ifdef kPaidVersion

//  Do Something For The Paid Version

#else

//  Do Something For The Free Version
 
What we did with CraigsHarvest and CraigsHarvest Lite is create two build targets and then use preprocessor macros to differentiate the two. This allowed us to take advantage of #ifdef, as well as specify other things that were different between targets, such as the icon, Info.plist, etc.
 
what u did for mine was i just copied the code and made a different project but I deleted the thing that i didnt want in the lite version it was simple and it worked
 
what u did for mine was i just copied the code and made a different project but I deleted the thing that i didnt want in the lite version it was simple and it worked
Perhaps. But now you have two projects / codebases to maintain. Could cause extra work to keep them in sync with future updates.
 
Perhaps. But now you have two projects / codebases to maintain. Could cause extra work to keep them in sync with future updates.

Couldn't you have two separate project files in the same folder, using the same class files?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.