Debug broken code highlighting in Xcode 4
If you use Xcode 4 a lot this might have happened to you, too: Coloring and code completion fail and do not come back. Which makes working with Xcode almost impossible
This happens when Xcode’s indexing process fails for some reason. This can be a header file is missing to code highlighting (which can be different from the compiler in some cases) or in some cases a bad
#define. The problem is that it fails silently so you cannot fix it.
After having this problem with a big project I stumbled onto the magic hint on Stack Overflow. After you quit Xcode enter this into a shell:
defaults write com.apple.dt.Xcode IDEIndexingClangInvocationLogLevel 3
After this you should open the project and see messages like this:
Xcode: IDEIndexingClangInvocation: Failed to save PCH file: /Users/user/Library/Developer/Xcode/DerivedData/Project-drsrrgaenperjadmqslqfxyqcqyt/Index/PrecompiledHeaders/Some-Prefix-cgepzuvkwimbsvcmqrbbpeoyhdpz_ast/Some-Prefix.pch.pth
Looking through these messages will show you what goes on and might help you finding the problem.
For me it was just copying header files from a framework on the place the Clang parser was looking for them.