Xcode: code loses syntax coloring

Viewed 44444

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?

15 Answers

I find that the following will often do the trick…

"Reselect" both "Base SDK" - and "Architecture" - in "Build Settings". (CLick on blue project icon in top left, while in "Browser mode", aka 1, then click project settings and mess with the stuff there.

Make sure they all line up / it doesn't hurt to do a little toggly-wogglying up in there, while you're in there… ya know just mix it up a bit. You'll notice xCode has a teensy-tiny mini-stroke - every time you switch between 64 and 32 bit… This is usually when I know if code highlighting is dead for the night, or if I'm good to go.

Often, I will have a project that gets highlighted instantly in 32 bit mode, and just sits there in 64… Who knows.. Ahh, Xcode, you wacky botch.

I can confirm a 100% fix for this problem, based on a question I had asked (and actually answered), as pictured below. One thing i will add is that sometimes it is "errant whitespace" that can also contribute to the loss of highlighting. Either clean it up yourself, or use the Goggle Toolbox for Mac Xcode 4 plugin, which adds an entry in the XCode Edit menu called Clean Up Whitespace.

enter image description here enter image description here

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).

Related