Macro Ignored in AppDelegate

This code worked in previous versions of XCode. I have a custom preprocessor macro defined that is respected everywhere except in my app delegate file. (iOS, Objective C)


#ifndef MY_MACRO

code

#endif


It is defined, but the enclosed code block is included anyway and caused errors. (Code is used in other versions.) This happens in two places. If I put in #define MY_MACRO before the first #ifndef, both blocks are (correctly) not included. Why would it ignore this preprocessor macro in just this one file? I even went through the project and replaced the macro with something guaranteed to be more unique, just in case of some kind of name conflict, to no avail.

Not sure what it is about that one file, unless perhaps your legacy project is now an OBJ-C/Swift hybrid...


As stated in Apple Docs

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.


See this SO thread for how to set custom flags...


http://stackoverflow.com/questions/24003291/ifdef-replacement-in-swift-language

Macro Ignored in AppDelegate
 
 
Q