Cherif
Cherif

Reputation: 5383

How to determine that my iOS app is running in DEBUG mode?

The code :

#if DEBUG
    let iAmInDebugMode = true
#else
    let iAmInDebugMode = false
#endif

The project settings :

enter image description here

The scheme settings :

enter image description here

The result :

println(iAmInDebugMode) // false

Why ? What am I doing wrong ?

Upvotes: 2

Views: 1829

Answers (2)

Adnan Aftab
Adnan Aftab

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

enter image description here

Upvotes: 4

vinoth.kumar
vinoth.kumar

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

Related Questions