通常的做法是在启动时设置一些变量
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{//...#if DEBUGNSFNetworkLayerLogging = YES;NSFModelLayerLogging = YES;//...
#endifreturn YES;
}
多人协作时,一个人调试时打开的开关,很可能会混在正常的修改里一起提交到仓库中,影响到其他人的配置。
解决方案
将开关移到Xcode的Environment variables设置里
然后
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//...#if DEBUGNSString *string = [[NSProcessInfo processInfo] environment][@"NSFModelLayerLogging"];NSFModelLayerLogging = [string boolValue];
#endifreturn YES;
}