Xcode code sense color/completion not working
EDIT: This is weird... if I double-click the Recent Projects item for the project in the welcome screen, code sense and coloring works just fine but if I just click Open
(bottom right in welcome screen) it doesn't. Opening from File > Recent projects
does not work either and neither does double-clicking the .xcodeproj
file in Finder.
Code sense for an iPhone OS 3.0 project I have been working on for several months (through different installations/versions of Xcode) is not working any more. For instance, if I do NSString *myString
, all code would be black (no coloring, no Option + Double Click, no code completion). Code Sense only "works" for my own classes/methods/properties but not for any of the SDK classes. If I create a new project from scratch I do have all of these working.
I already tried changing the "Base SDK for All Configurations" in this project. I already tried "Rebuild Code Sense Index". I already tried "Clean All Targets".
Documentation in the Preferences is all downloaded and working. For instance, if I select the NSString
above and do Right-Click -> Find text in documentation, I get the window with all the reference to the class.
Any ideas will be greatly appreciated.
In Xcode 4, I haven't been able to find a "Rebuild Code Sense" button either, but if you go to Window -> Organizer, select the Project tab, and click "Delete..." next to the Derived Data folder, it seems to have the same effect. (I got that tip from http://blog.slidetorock.com/xcode-4-code-sense-autocompletion-problems, which indicates that it got it in turn from https://stackoverflow.com/questions/2138047/xcode-code-loses-syntax-coloring - but I don't see it in any of the answers there. Very curious.)
Just run in terminal every time when needed
rm -fR ~/Library/Developer/Xcode/DerivedData
Works fine. Highlighting and codesense back to me! Sometime needed Make Clean to back it work.
note: as I see it's remove snapshost and another Xcode4 'features'. But we do not use it :)
Syntax coloring is working back after i do the following steps:
- Go to Organizer > Project > Delete Derived Data from your current project
- Clean & Build
- Close & Quit XCode, and reopen the project
- Syntax coloring becomes well after project reindexing
P.S.
- LLVM Complier 3.0
- i used -fno-objc-arc Complier Flags for all 3rd party libraries(e.g. ASIHTTPRequest)
- My project is created from XCode 4.2
I've had the same problem in Xcode 4 and solved it by changing the compiler from GCC 4.2 to LLVM GCC 4.2.
Get Info on the project in Xcode and change the Project Format to match the version of Xcode you're using (as of this writing, "Xcode 3.2-compatible").
You can delete the derived data as well, but unless you've updated your project format the bug will reoccur almost immediately. (It may happen even after updating your project format, but I used to have to delete DerivedData several times a day, and I think I've only done it once since fixing the project.)
As noted elsewhere, switching to LLVM may help. But as I update this answer (2012), you should be using LLVM anyway.