Search code examples
xcodeparsingsyntax-highlightingcode-completionpreprocessor-directive

Xcode: macros breaking completion/highlighting


From the Xcode Docs:

Syntax highlighting, code completion, and every other index-driven feature is handled by the LLVM parser. If the compiler knows about a symbol, so does the Xcode IDE.

but none of these "index-driven features" are working for me when writing code inside of a preprocessor directive. Does anyone have a solution for this?

Examples:

When building with Unused Parameter warnings turned on, tons of warnings are generated even when said parameter is used. The code in this specific screenshot is from Apples Reachability.m and is unmodified. Notice that syntax highlighting is also nonexistent here:

Warnings

Correct completion inside #if:

Correct Code Completion

But, incorrect completion inside #else:

Incorrect Code Completion

It half works with local variables:

Broken Parsing in UIDeviceOrientationIsPortrait Macro

But breaks again when calling something declared outside of the current method scope:

Broken Parsing in UIDeviceOrientationIsPortrait Macro

Another example
Another example

Can anyone please tell me how (or even if) this can be fixed?


Solution

  • Turns out this was a bug and is now fixed in Xcode Version 4.3.1 (4E1019).