43

My project was created in Xcode 3, I'm opening it in Xcode 4 and notice the following:

  • 'Jump to Definition' no longer works with my own symbols (However UI* and even TT* symbols do work fine!)
  • Auto-complete / 'Code sense' is as bad as Xcode 3, i.e., it suggests everything
  • My projects' classes do not show up in the class navigator (Again, system and Three20 classes do show up!)

When creating a new Xcode 4 project however, these features do seem to work. Unfortunately the only workaround seems to be to recreate the project and re-import everything. This project is too large!

Things I've tried:

  • Removing the derived data in the organiser
  • Cleaning the project
  • Installing both Xcode 4 Gold Master and Final versions

Update

  • This bug has not been resolved in Xcode 4.0.1.
8
  • I have this problem as well - have tried reindexing to no avail. Anyone able to suggest something else? Mar 15, 2011 at 14:40
  • Same problem. Works fine for new/spall projects, but with my existing, large project it works badly.
    – Nick Moore
    Mar 18, 2011 at 14:26
  • seems like small projects work just fine
    – hfossli
    Apr 1, 2011 at 7:41
  • I have this problem as well, seems to still be a problem in 4.0.2 too.
    – makdad
    May 15, 2011 at 23:36
  • Me too on 4.0.2 - works for 10-20 minutes at a time, then autocomplete can't even find the foundation classes anymore. Building, cleaning, restarting Xcode helps 50% of the time, the other half of the time it comes back after 10-20 minutes of me working without autocomplete.
    – RickiG
    Jul 31, 2011 at 15:11

15 Answers 15

67

On Window Menu:

  1. Organizer
  2. Projects tab
  3. Your Project
  4. Delete Derived Data
  5. Restart Xcode

A little tip from other's answer:

After step.4 don't rebuild the project but just restart Xcode.

3
  • 2
    See my comment above, but I always fix it by simply touching the .pch file in my project. I used to also delete Derived Data, but this seems faster. (I made an alias in my .bashrc to touch the .pch file. No restart required)
    – Eric G
    Mar 12, 2012 at 19:24
  • This brings back autocomplete, but it also ruins the included project - RestKit in my case.
    – Hlung
    Mar 23, 2012 at 9:12
  • I tried the above steps, but "Jump To Definition" is still greyed out for me.
    – jowie
    Aug 23, 2013 at 11:51
16

What worked for me when i lost xcodes super nice code hinting was:

Window(menu) -> Organizer(menu) -> Projects(tab)

then

Press delete Derived Data (this is the same as going to the folder and deleting it manually)

BUT!!!!! at this step dont rebuild but shut down xcode and reopen of the project. This worked for me.

0
7

I had the same problem in XCode 4 final version today, working with my old XCode 3 project. The problem is related to an index of symbols that XCode creates. It should create a new index for you automatically, but it seems to take a long time in XCode 4. One possible solution is to go to ~/Library/Developer/Xcode/DerivedData and delete the old index. Restart XCode, and you should see it indexing. For 'Jump to Definition', you can hold down command and mouse over a method or class name, and you should see blue underlines, like hyperlinks. Then you can click on it to jump to definition.

2
  • Doesn't work, mark down. The accepted solution should be to POUND APPLE WITH BUG REPORTS SO THEY CAN FIX THIS IN XCODE 4! Dec 22, 2011 at 17:27
  • This works for me, but only for a minute or two. Then it back to being broken again :(
    – Sunkas
    Jun 7, 2012 at 16:09
7

EDIT: It seems that if you have any custom header search paths to support multiple targets with shared code XCode 4 indexing will break and then assistant and codesense along with it. I have raised this as #ID 9182099 with Apple. There is also an issue that if you have any conflicting settings between project global and target specific build settings the index will fail to complete correctly. Make sure that your build settings are consistent.

I have just had this problem in a very large, multi target commercial project. As an additional pain all of the xib files would not show the controller in assistant view and none of the subclass/superclass/siblings/categories assistant views would work either.

After much searching and experimentation with deleting the indexes etc I was forced to create a new empty project and re-import everything. I know you have said that your project is too big for this but I dont think there is any other option available. In the end it has taken me most of a day to migrate my project completely. I suppose you could hold on hopefully for a resolution in a future point release but I chose to bite the bullet now to benefit from the productivity increases from the new features.

To achieve this I created a new "empty" project and then manually recreated the targets I needed. I then deleted the source and .plist files for the new targets leaving me again with an empty project with the three targets I needed.

I then just selected "add files.." to the project one folder at a time linking against target as required. I stopped and built each target as it was imported to deal with any compiler errors that the latest clang gave me.

If you have a complex group hierarchy that is not mapped to a file system folder structure then you will either need to recreate the groups after import or go through the painful process of moving all your files into subfolders and re-pointing the references in XCode.

You will also need to carefully check any custom build settings in the targets as well as relink any libraries you include. Also make sure you remove any bulk imported .plist files from the target linking.

Sorry if this is not the answer you had hoped for.

7
  • 1
    12 Hours after writing this and my XCode project has once again lost all the assistant views for everything other than counterpart. I thinking this must be a bug in XCode 4 now.
    – Rick
    Mar 24, 2011 at 9:06
  • I'm having the same problem. You may be on to something. Mar 30, 2011 at 22:25
  • While I've not tried re-importing into a new project I did have some luck with custom header paths - i.e. adding a path to the project root at one point seemed to force it to re-index. However, it has also now broken again!
    – Jimmy
    Apr 4, 2011 at 10:44
  • Hi, Rick. I thought it might be a good idea to update the original text to make it a little more clear that it didn't work. It wouldn't be too fun to go through the process you described before reading the comment where you mentioned that it doesn't work.
    – wbyoung
    Apr 19, 2011 at 20:18
  • @wbyoung The actual process to get a clean project going still holds. I hoped my edit at the top would show that there are possible gotchas even after taking the long route.
    – Rick
    Apr 20, 2011 at 16:07
4

http://three20.info/article/2011-03-10-Xcode4-Support worked for me. Specifically erasing the Build directory of three20. Strangely it worked even when the said build was made in xcode4. CodeSense started working the moment I erased the three20 build dir, I didn't even have to recompile or reload the project.

2
  • Actually it seems that I need to keep erasing the said dir after every build. Making those test builds quite slow.
    – GreatWiz
    May 15, 2011 at 19:33
  • Worked for me. My problem was because i moved my project from one computer to the other.
    – clenemt
    Aug 29, 2011 at 14:05
2

This just worked for me:

  • Open your Xcode project.
  • Open up a command prompt in your project directory and type:

    touch MyProject.xcodeproj/project.pbxproj

  • Watch as syntax coloring and other stuff gets fixed before your eyes.

  • Reopen your project (or adjust a project setting) if your project schemes get reset to "My Mac" for iOS projects.
2

I fixed the problem by removing derived data in th Organizer, running touch MyProject.xcodeproj/project.pbxproj and re-opening the project. After re-opening it, it started indexing and then it was working again.

0
1

In our case the culprit turned out to be old version of the three20 libs. To get the project working I had to:

  1. Remove all references to three20 from the project
  2. Follow the instructions at http://three20.info/article/2011-03-10-Xcode4-Support

As soon as the new library was installed, xcode4 automatically reindexed. Code completion, jump to definition and even Refactor all work now. The Joy(tm) of working with Xcode is back! :)

In more general terms, any library that puts it header files into BUILT_PRODUCT_DIR is likely to have similar issues.

2
  • Outstanding! It's such a coincidence that my project also uses the Three20 library!
    – Jimmy
    Apr 18, 2011 at 10:08
  • 1
    three20 isn't the only problem, I'm not even using that and the indexing is disabled whenever I update from GIT. It's an Xcode 4 bug. Probably the biggest barrier in iOS development right now! Dec 22, 2011 at 17:26
1

In my XCode 4 setup, it is 100% reproducible that setting the User Header Search Path will break codesense, especially "Jump to Definition", after a restart. I have create a new project, added my helper library as a subproject. If I include the headers with the User Header Search Path (recursive), I can compile, but autocomplete/navigation is broken.

Deleting the header search path, closing the project, and reopening, fixes it again.

1
  • This appears to work for me, but only for autocomplete and not for "jump to definition". Just by toggling recursive on one of my header paths, attempting to build, then toggling back, building again.
    – gak
    Sep 16, 2011 at 21:51
1

Added this as a comment in a few places as well, so maybe Google juice will help get programmers up and running again... but anyway, I found if you just use the touch command on the YourAppName-Prefix.pch file it will get syntax highlighting/coloring and code completion/jumping back on without having to delete all your derived data or restart Xcode. I made this an alias in my .bashrc file.

alias pch_touch='touch /path/to/your/apps/Prefix.pch'

. ~/.bashrc

Within about 1-2 sec of touching the pch file, syntax coloring comes back on, which is a sign code completion/jumping will be now working too. Kind of sad such an otherwise awesome powerful tool is humbled by some metadata / statefulness bugs, but there ya go. At least it gets you back up and running and stops wasting your time.

0

I had the very same problem here. No definition links, code sense or syntax highlighting. Removing derived data didn't work and even creating a new project did not make any difference. While it may not be the same problem you have, cleaning up the build settings (so that there are no conflicts between project and targets) like Rick said solved it for me (though I still don't know which setting(s) was/were causing the problem).

0

With regard to "Jump to Definition", try clicking on the Scheme selection button (the one near the top right of the window that displays a list of builds, devices, and simulators) then click back in the code editor and try Command-click or "Jump to Definition" again.

I've recently found that whenever "Jump to Definition" stops working I can do this and it works again for awhile. It's not a fix but has been a useful workaround.

0

I don't know if it helps someone, but I got the code indexing of my C++ project broken when I switched to Xcode 4. I haven't switched to Lion so I still have the 4.02 version. When creating the project in Xcode I would use the external build option, this didn't add the HEADER_SEARCH_PATHS correctly to the project. I found that using:

   cmake -G Xcode . 

to generate the xcode project, sets this variable correctly and enables the indexing of the entire project.

0

I had this exact same issue. I have a project with a bunch of ViewControllers that extend a class I'm calling BaseViewController. I added the following code to BaseViewController.h and syntax coloring and code autocomplete broke! Even with repeated deletions of derived data the problem was still there. I can't believe it!!

@implementation UIView (FindFirstResponder)
- (UIView *)findFirstResponder
{
    if (self.isFirstResponder) {
        return self;
    }

    for (UIView *subView in self.subviews) {
        UIView *firstResponder = [subView findFirstResponder];

        if (firstResponder != nil) {
            return firstResponder;
        }
    }

    return nil;
}
@end

Commenting out this code solved my issues! I have XCode Version 4.4.1 (4F1003)

0

From this comment here I was able to debug a similar problem with my project, it seemed to be a bad -w flag that the clang preprocessor wasn't recognizing properly. Basically, running

defaults write com.apple.dt.Xcode IDEIndexingClangInvocationLogLevel 3

in Terminal increases the verbosity of the indexer, and should help you track down issues. Run Console.app and search for IDEIndexingClang.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.