6

XCode frequently seems to lose it's mind, and doesn't color code system classes or provide correct "code sense" suggestions. This is endlessly frustrating. The question has been asked on at least three other occasions:

Problems with Xcode Syntax Highlighting

xcode code sense color/completion not working

Xcode: code loses syntax coloring

I have switched by project version to/from 3.1-compatiable and 3.2-compatiable, completely restarting XCode before and after each change with no effect.

I have rebuilt the code sense indexes and completely restarted XCode with no change.

I have built my project to make sure there are no errors and restarted.

I have copied my files (sans .svn files) to a different location - same problem.

I've already completely disabled the argument "placeholders" because they screw up my documents when i type too fast... all I'm asking for is for the "esc" key to display the correct list of properties and methods.

Community
  • 1
  • 1
Steve
  • 31,144
  • 19
  • 99
  • 122

2 Answers2

12

You should clean your project's derived data. They are likely corrupted.

Go to Organizer > Projects > Your_Project > Derived Data > Delete

Xcode will reindex your project and you should be back to normal.

KPM
  • 10,558
  • 3
  • 45
  • 66
  • Thanks for the input, but I had answered my own question two years ago. It was a problem with code inside a precompiler directive. – Steve Mar 13 '12 at 14:45
  • Sure, I saw that. I was just giving another indication for people that might be experiencing the same problem as you, but not for the same reasons (it was my case). – KPM Mar 13 '12 at 16:01
7

For anyone interested; my app has some precompile directives:

#if ...

Turns out there was an error in one of these sections.

I'm assuming my app built fine because these sections were stripped out before they ever got to the compiler... but CodeSense doesn't care about these (it still wants to color code everything inside these) - so CodeSense would puke all over the place because of the error, even though I didn't find it when I tried to build the app.

Once I fixed the error within that block of code, my coloring returned.

Would be nice if XCode just greyed out those sections instead of dying.

Steve
  • 31,144
  • 19
  • 99
  • 122
  • PS.) I posted a bug report with Apple and received the following response: Hello Steven, This is a follow up to Bug ID# 8069971. After further investigation it has been determined that this is a known issue, which is currently being investigated by engineering. This issue has been filed in our bug database under the original Bug ID# 4824854. The original bug number being used to track this duplicate issue can be found in the State column, in this format: Duplicate/OrigBug#. – Steve Jun 10 '10 at 04:19
  • I think I found a workaround. See my answer here: http://stackoverflow.com/questions/2138047/xcode-code-loses-syntax-coloring/ – Lars Schneider Oct 06 '11 at 15:21
  • After a month of banging my head over this issue, with none of the fixes online actually working, I finally fixed this in my project the same way you did, by fixing an incorrectly done `#ifdef`. I had never noticed the error before and GCC didn't flag it as a warning. Just switched to LLVM today, which did flag a warning, and as soon as I fixed it, deleted derived project data, and reindexed it's working great now! – Ben Baron Oct 28 '11 at 19:49
  • @einsteinx2 - I know, it's terrible, isn't it!? – Steve Oct 28 '11 at 20:03
  • I'm literally ecstatic now that I have highlighting and code complete back. It was such a PITA to go months without it. I made do, but everything was more time consuming, and code was harder for my brain to parse. SOOOO HAPPY RIGHT NOW!! :) – Ben Baron Oct 28 '11 at 20:08