Avatar ·

Replacing #ifdef in Swift: Conditional Compilation and Build Configurations

Hello everyone! I just started learning Swift after C++ and ran into a problem. In C++, I often used the preprocessor directives `#ifdef`, `#ifndef`, `#endif` for conditional compilation of code — for example, to include debug code only in a Debug build or to support different platforms. In Swift, I didn't find a direct analog of `#ifdef`. I tried to write something like: ```swift #ifdef DEBUG print("Debug information") #endif ``` But Xcode gives an error. I read the documentation — there is `#if`, but it doesn't work the way I'm used to. For example, I want to: 1. Add additional logging only in Debug mode. 2. Exclude entire blocks of code for iOS but keep them for macOS. 3. Hide test stubs in the release build. How to properly organize conditional compilation in Swi