开发者

Changing app setting during the Xcode build process

I have config files (as plist) that contain information used by the app to connect to web services. I have a file for each of our deployment domains (DEV, PRODUCTION) for obvious reasons(different URLs). So I have plist for each domain in my project e.g 1. myConfig.dev.plist 2. myconfig.prod.plist

I have multiple targets - one for each domain t开发者_StackOverflow中文版hat I am building for. In the target I have scripts that rename the file to myConfig.plist. All these work fine. However I was wondering if there was an easier way to do this instead of having multiple targets.


You can use XCode 4's new build schemes and have custom environment variables.

NSDictionary *environment = [[NSProcessInfo processInfo] environment];
NSObject *isDevEnvironment = nil; // set to nil to avoid garbage memory
isDevEnvironment = [environment objectForKey:@"isDevEnvironment"];

if(isDevEnvironment) {
  // Do stuff
} else {
  // Do other stuff
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜