Created
May 23, 2020 14:46
-
-
Save palaniraja/58fb57124bb57cbb36342a458a9c0ce4 to your computer and use it in GitHub Desktop.
Conditional logging to strip logs in release builds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if DEBUG | |
class Log { | |
static func d(_ str: String){ | |
print("Log.d: \(str)") | |
} | |
} | |
#else | |
class Log { | |
static func d(_ str: String) { } | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As you can see in the screenshots above, the debug messges printed to console using
Log.d
are stripped from-release
binary. I usedStrings
to verify if the binary contains the strings used withLog
statements.