#if DEBUG vs. Conditional(“DEBUG”)

Which is better to use, and why, on a large project: #if DEBUG public void SetPrivateValue(int value) { … } #endif or [System.Diagnostics.Conditional(“DEBUG”)] public void SetPrivateValue(int value) { … } 8 s 8 It really depends on what you’re going for: #if DEBUG: The code in here won’t even reach the IL on release. [Conditional(“DEBUG”)]: … Read more

#ifdef replacement in the Swift language

In C/C++/Objective C you can define a macro using compiler preprocessors. Moreover, you can include/exclude some parts of code using compiler preprocessors. #ifdef DEBUG // Debug-only code #endif Is there a similar solution in Swift? 18 s 18 Yes you can do it. In Swift you can still use the “#if/#else/#endif” preprocessor macros (although more … Read more