Per-File Compiler Flags in Xcode 4
I had written previously (twice) about missing debug symbols and strangeness related to compiler optimization in Xcode. I’d specifically mentioned per-file compiler flags. You may be wondering where they went in Xcode 4. “Ur flagz … let me show you them.”
The “old way” (Xcode 3 and lower) was per-file. That is, no matter the build target, the same source file would use the same per-file compiler flags. In Xcode 4, you have somewhat better control as you’re now allowed to set per-file flags per-target. That is, select your project in the Project Navigator, select the relevant target (you may have only one), then select the Build Phases tab. Expand the Compile Sources phase and viola! A Compiler Flags column lets you set each file’s flags for that target.
It would be nice to be able to further break it down into per-file-per-target-per-build-configuration so we can only apply -funroll-loops and -O3 to targets built for release. That’d save a lot of headaches when you’re suddenly jumping around wildly in the debugger when you enter a for loop.