Skip to content

Instantly share code, notes, and snippets.

@palaniraja
Created May 23, 2020 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save palaniraja/58fb57124bb57cbb36342a458a9c0ce4 to your computer and use it in GitHub Desktop.
Save palaniraja/58fb57124bb57cbb36342a458a9c0ce4 to your computer and use it in GitHub Desktop.
Conditional logging to strip logs in release builds
#if DEBUG
class Log {
static func d(_ str: String){
print("Log.d: \(str)")
}
}
#else
class Log {
static func d(_ str: String) { }
}
#endif
@palaniraja
Copy link
Author

palaniraja commented May 23, 2020

logd-vc

logd-strings

As you can see in the screenshots above, the debug messges printed to console using Log.d are stripped from -release binary. I used Strings to verify if the binary contains the strings used with Log statements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment