Question

I would like to load different plist files based on what stage of the app (or profile) I am attempting to build...

For instance... in dev I want to add a plist that contains strings for our api on a dev server, in beta I want to add a plist that contains strings for our api on a bata server, etc.

What is the best way to do this?

Thanks.

Was it helpful?

Solution

Prepare different plist file, and as VGruenhagen mentioned, use the Preprocessor Macros. You may want to do centralize into something like this:

+(NSString*)plistFileName {
#ifdef _DEV
    return @"data_beta.plist";
#elseif _BETA
    return @"data_beta.plist";
#else  // Release ?
    return @"data.plist";
#endif
}

OTHER TIPS

The best way might not be using plist at all, if all you need is the string for your api.

You may want to look into the Configurations in Info and Preprocessor Macros in Build Settings. For example, you would want to create a Beta and Dev configuration.

Then you would want to set under the Macro for Beta, BETA = 1. While Dev would be DEV = 1.

In your code you would have a define if BETA is true and another for Dev that sets your string for your api. Once that is done all you would have to do is run project using the Dev or Beta Scheme depending which one you want.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top