Xcode 4: Auto-complete & Jump to Definition broken in my Xcode 3 Project
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* s开发者_如何学JAVAymbols 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.
On Window Menu:
- Organizer
- Projects tab
- Your Project
- Delete Derived Data
- Restart Xcode
A little tip from other's answer:
After step.4 don't rebuild the project but just restart Xcode.
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.
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.
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.
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.
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.
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.
In our case the culprit turned out to be old version of the three20 libs. To get the project working I had to:
- Remove all references to three20 from the project
- 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.
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.
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.
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).
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.
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.
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)
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
.
精彩评论