Settings bundle for iPhone app

后端 未结 1 637
无人共我
无人共我 2021-01-05 12:19

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

相关标签:
1条回答
  • 2021-01-05 12:33

    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
    
    0 讨论(0)
提交回复
热议问题