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 curre开发者_开发知识库nt 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.
I've answered a related question few hours ago (iPhone - Switching between local and production environment settings).
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
精彩评论