Reputation: 5383
The code :
#if DEBUG
let iAmInDebugMode = true
#else
let iAmInDebugMode = false
#endif
The project settings :
The scheme settings :
The result :
println(iAmInDebugMode) // false
Why ? What am I doing wrong ?
Upvotes: 2
Views: 1829
Reputation: 14477
In swift it will not work like this, you need to set flag inside other swift flags -D DEBUG
then it will work. You can get more details about build configuration flags here
Upvotes: 4
Reputation: 92
Run time
NSDictionary* env = [[NSProcessInfo processInfo] environment];
if ([[env valueForKey:@"debugger"] isEqual:@"true"]) {
NSLog(@"debugger yes");
}
else {
NSLog(@"debugger no");
}
Compile time
#ifdef DEBUG
// Something to log your sensitive data here
#else
//
#endif
Upvotes: 2