objective-c - Switching between development environment and release environment in iOS project to facilitate testing
三叔
三叔 2017-06-10 09:48:16
0
1
1068

The current requirement is: add a line to the settings list in the APP for cells dedicated to switching server environments for special accounts, so that you can freely switch between development, testing, and formal environments.

Currently, the global macro definitions are all written in the PCH file. I want to use NSUserDefault or Singleton to maintain the environment variable collection, but it has no effect. However, using Build Configuration to configure multiple environments, using xcconfig files to configure multiple environments, and using Targets to configure multiple environments, these methods will package multiple APPs and the configuration process is not simple. In fact, there should be a simpler way to implement a small function of switching between multiple environments. I hope interested students can answer this question.

三叔
三叔

reply all(1)
漂亮男人

Use NSUserDefault, and then define the macro APIHost to determine the value based on the NSUserDefault value

#define ServerHost [[NSUserDefaults standardUserDefaults] objectForKey:@"xxxxx"]?releaseHost:debugHost
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template