I have a preprocessor macro in my XCODE project called LINPHONE_DEBUG. In my build settings, I have set the macro to 0 exactly like this: LINPHONE_DEBUG=0.
But somehow when I use this code:
#if LINPHONE_DEBUG
foo()
#endif
The foo() is still called see the screenshot below.

You can see that I printed po LINPHONE_DEBUG and it is 0, but it still reached the code.
I am running XCODE 6.4 (6E35b).
From the Swift iBook: Using Swift with Cocoa and Objective-C (Swift 2 Prerease)
“The Swift compiler does not include a preprocessor. Instead, it takes advantage of compile-time attributes, build configurations, and language features to accomplish the same functionality. For this reason, preprocessor directives are not imported in Swift.”
“Build Configurations Swift code and Objective-C code are conditionally compiled in different ways. Swift code can be conditionally compiled based on the evaluation of build configurations. Build configurations include the literal true and false values, command line flags, and the platform-testing functions listed in the table below. You can specify command line flags using -D <#flag#>.”
See the documentation for more information on Build Configurations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With