1

I am working in a team and recently we have lost all of our syntax highlighting in our Xcode project. It is a problem across all of our environments, so it's not a problem with the local machine. We have all cleared our derived data, deleted the precompiled headers in /var/folders/. Also, everyone is getting the following error in their console:

1/12/12 9:40:42.126 PM Xcode:  IDEIndexingClangInvocation: Failed to save PCH file: /Users/sashimiblade/Library/Developer/Xcode/DerivedData/Project-gfgcpcthwcmainhhtgpavaqacqkr/Index/PrecompiledHeaders/Project-Prefix-gwxtmfzfhffkhmardmbbgmpwrntg_ast/Project-Prefix.pch.pth

Any ideas? This has been driving me nuts for several days and I just cannot live without my Autocomplete or syntax highlighting!

Dr.Kameleon
  • 22,532
  • 20
  • 115
  • 223
sashimiblade
  • 620
  • 7
  • 21
  • The only time I have seen autocomplete failing to work was post-upgrade, when the documentation sets were for some reason purged. Check Xcode preferences under Downloads and make sure the documentation there is listed as `Installed`! Not sure about the indexing error. –  Jan 13 '12 at 02:48
  • When did it start happening? Are you under source control? If so, maybe you can narrow it down to a checkin and see what changed in some project file?? – bryanmac Jan 13 '12 at 02:53
  • That console error suggests that it's trying to put derived data in the *system* library (`/Library`) rather than the user library where it would normally live. (It says `/Users/../Library` which is equivalent to `/Library`.) This is unusual and wrong. I'd check to see what's changed in your build settings. It does sound like something has become corrupted. Presumably you can't build either? – Tim Jan 13 '12 at 03:01
  • The strange thing is that I can build, and everything works fine in the binary, just the code highlighting and autocomplete are gone. – sashimiblade Jan 13 '12 at 14:29
  • Glad you solved your problem. I had similar issues, and have documented a general solution (that doesn't involve continually restarting Xcode!)... See my answer here: http://stackoverflow.com/a/10245076/123632 – Ashley Mills Apr 20 '12 at 11:49

2 Answers2

1

I'm not trying to get any rep - just want to make what @EricGoldberg and @CornPuff mentioned in the comments above stand out. It simply is a HUGE time-saver.

Autocompletion gone in Xcode? (quite a usual occurence to be honest)

Just follow this super-easy steps :

  • Add a new line (or any other simple edit, for that matter) to your YourAppName-Prefix.pch file

  • Save

  • Rebuild your project

And, it's auto-magically fixed! :-)

Dr.Kameleon
  • 22,532
  • 20
  • 115
  • 223
  • That strategy usually works, but I think that it's basically equivalent to deleting your derived data (which should delete the precompiled headers relevant to your project). I believe that when you change your .pch file or delete your derived data, the compiler re-compiles all of the relevant headers in your .pch file to bring the build environment's symbols up to date. When I feel like there's a problem, I usually just delete all the derived data (In Organizer->Projects->Your Project->Delete button next to "Derived Data") just to make sure nothing's messing with the environment. – sashimiblade Feb 18 '13 at 05:16
1

Ok, I figured it out. I had Core-Plot in the framework area of my project, and Xcode was looking to resolve Core-Plot as a framework even though it was just a binary and the associated headers. So I moved Core-Plot into a folder with my other classes, removed the old Core-Plot path from the library search paths and also blew away the header search paths and now my autocomplete and code highlighting is back!! I think this is a bug in Xcode...

sashimiblade
  • 620
  • 7
  • 21
  • 2
    Yes, CodeSense tends to crap out 2-3 times per day for me as well. I just usually touch my Prefix.pch file and that fixes everything. I even wrote a simple script called pch_touch that lets me touch the pch files for all my various projects. Pretty awesome stuff. – Eric G Apr 17 '12 at 00:29
  • 1
    Awesome. I added a newline to my .pch file and hit command-b and everything worked together. I never know how much I loved autocomplete until it was gone! – CornPuff Jul 23 '12 at 22:08
  • 1
    @Eric that is really nice, I just did the same on the .pch file and sintax highlighting came back. I use instead to delete all the derived data folder. Perhaps you should write as an answer somewhere. – Leonardo Sep 17 '12 at 11:24
  • @Leonardo I have added it as an answer 2-3 places. :) But I think Xcode 4.4 or 4.5 finally fixes this issue (see the release notes) – Eric G Sep 18 '12 at 02:36