3

I am trying to make a lite version to my iPhone App. I followed this tutorial to the dot and copied the target. Everything there went great but when I enter -DLITE_VERSIONinto the LLVM GCC 4.2 - Language setting in the build tab, the define does not work correctly. When I enter #ifdef LITE_VERSION, I build without errors but yet the button that I am trying to set as hidden is still showing. Any idea's. BTW I change the active scheme by selecting it from the bar right next to the run button on the top left of xcode 4.

Here is my code:

#ifdef LITE_VERSION

    [play setHidden:YES];

#else
    [play setHidden:NO];
#endif
Yo_Its_Az
  • 2,043
  • 2
  • 18
  • 25
  • when you set your “play” button to hidden without preprocessor directives, is it really hidden ? if no, maybe your code is setting the hidden property to YES somewhere else. – teriiehina Jul 16 '11 at 17:24

1 Answers1

1

What I did is defined a #define in the -Prefix.pch of my lite version like so:

#define POSTPASSFREE 2

In my 'pro' version I have this #define:

#define POSTPASS 1

I then used conditional compilation, similar to what you have above in those areas where things need to be slightly different:

#if POSTPASSFREE
    return NO;
#else
    return YES;
#endif

Using both:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
#if POSTPASS
    return 2;
#elif POSTPASSFREE
    return 1;
#endif
}

Switching between schemes will activate the various sections at build time.

Wayne Hartman
  • 18,369
  • 7
  • 84
  • 116
  • But my main app is the only one with a prefix.pch. My lite version does not have it. All I did was duplicate the main game target and changed the name and bundle id in the plist. How should I make/find my lite versions prefix.pch? – Yo_Its_Az Jul 16 '11 at 05:38
  • @MacN00b - Looks the tutorial created the new target in a completely different way than I did. I used the Xcode 4 menu (File--> New--> New Target) to create my new target, which created a new Info.Plist, main, and pch file for my target. – Wayne Hartman Jul 16 '11 at 16:11
  • you can set the prefix header file for a target in the build settings - ie make a copy for the lite version (which you edit). search for "Prefix Header" under build settings for the new target, and you will see a line something like "myApp/myApp-Prefix.pch" - change it to the name of the (new) pch file ( eg myApp/myApp-Lite-Prefix.pch – unsynchronized Oct 16 '13 at 23:26