I want to add preprocessor macros for a couple files in my project, but not all the files. They're 3rd party sources, so I don't want to edit the files, as to avoid merge maintenance hassle when new versions come along. They happen to interfere with #defines used in other files in the project.
Can XCode 4 compile only certain files with different preprocessor settings than the others?
In your target's Build Phases tab, you can set compiler flags for individual files under the Compile Sources drop-down. GCC provides a lengthy list of options, but they should work equally well for LLVM.
To define a macro, say FOO, for a specific file, add the -D FOO flag to the "Compiler Flags" entry next to that file.
To un-define a macro FOO, add the flag -U FOO.
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