views:

29

answers:

1

We have a development environment with a lot of different settings for our sandbox instances, staging servers, and production environment.

In our iphone code, we keep these settings organized in plists.

Anyone have references to best practices for managing the swapping out of plists based on the current environment? Without having to manually change files, or worry about committing development environment changes to the repository? Ideally it would just be a build argument switch or something.

+1  A: 

Hi morticae,

I've answered a related question few hours ago (http://stackoverflow.com/questions/2063922/iphone-switching-between-local-and-production-environment-settings/2063992#2063992).

Put this code where you need to use the configuration based on the mode (debug/release) = (development/production).

The best place to put it is on the "ProjectName"_Prefix.pch file.

#ifndef __OPTIMIZE__ // __OPTIMIZE__ is not enabled, it means that the active config is Debug/Development, so here you have to put your code for development mode

// For example
#define SERVER_URL @"http://my.test.server/something"
#define PLIST_NAME @"developmentSettings"

#else //__OPTIMIZE__ is defined, so put here your production code

// For example
#define SERVER_URL @"http://my.production.server/something"
#define PLIST_NAME @"productionSettings"

#endif // __OPTIMIZE__

Cheers,
VFN

vfn
Looks like a good method for some things. Since asking this, I've gotten a little more familiar with the build process, and I think most of the issues can be addressed by simply maintaining different build Targets for the project. Still, this might come in handy, thanks.
DougW