Xcode 4: Auto-complete & Jump to Definition broken

2019-03-08 01:45发布

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.

15条回答
Animai°情兽
2楼-- · 2019-03-08 02:04

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)

查看更多
Deceive 欺骗
3楼-- · 2019-03-08 02:06

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

查看更多
该账号已被封号
4楼-- · 2019-03-08 02:12

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.

查看更多
可以哭但决不认输i
5楼-- · 2019-03-08 02:14

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.

查看更多
Deceive 欺骗
6楼-- · 2019-03-08 02:15

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.

查看更多
Emotional °昔
7楼-- · 2019-03-08 02:15

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.

查看更多
登录 后发表回答