views:

461

answers:

2

I find that in various situations Objective-C code in Xcode 3.1 (Leopard) can fail to get appropriate syntax coloring after typing or lose coloring that it had.

This isn't just a "refresh" issue with new custom symbols -- but affects Cocoa framework symbols as well.

Sometimes CMD-a to select all text on the code page will make the coloring (re)appear, sometimes double-clicking on a line to select it will work, sometimes I have to add/delete a space in a symbol to get that symbol to (re)color. Rebuilding, or closing/reopening the project may or may not work.

Is this a known issue with Xcode? For something so annoying to me, I'm not finding the plentiful discussions of it on SO and elsewhere I'd expect.

And is there any command to force global syntax recoloring?

A: 

Open the project settings (Project > Edit Project Settings menu) and then click the Rebuild Code Sense Index button in the General tab. This will recreate the index that Xcode uses for syntax coloring.

This process can take a while for larger projects, so you can check the progress in the Activity window (Window > Activity menu).

Rob Keniger
Time after time this doesn't fix the problem for me. I must be doing something wrong, as XCode simply doesn't bother highlighting syntax or displaying the auto completion.
Jessedc
Please make sure that you log bugs against Apple about these kinds of problems: bugreport.apple.com.
Lyndsey Ferguson
+1  A: 

I recently had a similar issue, all coloring and autocomplete stopped working for built-in frameworks, my own classes still worked. Someone recommended to me that I turn off "Run Static Analyzer" in the build settings. It's weird, but it worked.

Cory Kilger