Different Build Configs for free and pay versions

Discussion in 'iOS Programming' started by wlh99, Sep 11, 2009.

  1. wlh99 macrumors 6502

    Joined:
    Feb 7, 2008
    #1
    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.
     
  2. Darkroom Guest

    Darkroom

    Joined:
    Dec 15, 2006
    Location:
    Montréal, Canada
    #2
    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"]];
    
     
  3. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #3
    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.
     
  4. North Bronson macrumors 6502

    Joined:
    Oct 31, 2007
    Location:
    San José
    #4
    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
     
  5. North Bronson macrumors 6502

    Joined:
    Oct 31, 2007
    Location:
    San José
    #6
    Ahh, yes. You're right. I missed that. :eek:
     
  6. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #7
    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.
     
  7. hoosierfan24 macrumors member

    Joined:
    Jul 31, 2009
    #8
    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
     
  8. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #9
    Perhaps. But now you have two projects / codebases to maintain. Could cause extra work to keep them in sync with future updates.
     
  9. ghayenga macrumors regular

    Joined:
    Jun 18, 2008
    #10
    Couldn't you have two separate project files in the same folder, using the same class files?
     

Share This Page