Since there is no preprocressor in Swift, what replaces C macros?
cocoa, swift
Solution
Swift doesn't have a preprocessor and can't use C macros. There are some alternatives though. For constants you can just use a let statement. For example:
let defaultHeight = 100
There is also some support for build configurations. They have this format.
#if build configuration && !build configuration
statements
#elseif build configuration
statements
#else
statements
#endif
You can replace "build configuration" with the functions `os()` and `arch()` that return true or false. `os()` can take OSX or iOS as arguments while `arch()` can take x86_64, arm, arm64 and i386 as arguments.
You can see more about how Swift replaces C macros here
Problem
Is there a way to do #define, #ifdef and the other powerful macros in Swift?