Settings bundle for iPhone app

廉价感情. 提交于 2019-12-19 03:19:03

问题


Right I am developing an app that has two lots of settings Dev and Live. Is there a way to distinguish which lot of settings should be used based on whether the app is live or still in development or do I have to change the whole settings files before it goes live.

I was unsure on how to put this so if your not sure place just ask.


回答1:


What you want to do is define a Preprocessor Macro based on your build configuration. So if you have a build configuration called dev and one called live you would define a different value for dev and live.

To implement this go into your apps build settings in Xcode and search for "Preprocessor Macros". Add a macro for each build target.

For dev you could add:

APP_CONFIG=0

And for live you could add:

APP_CONFIG=1

Then in your code you are able to distinguish between dev and live build configurations by a simple if statement:

#if APP_CONFIG == 0
    NSLog(@"This is the dev build.");
#else
    NSLog(@"This is the live build.");
#endif


来源:https://stackoverflow.com/questions/8743914/settings-bundle-for-iphone-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!