Xcode 4:在我的 Xcode 3 项目中自动完成并跳转到定义中断
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5275004/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode 4: Auto-complete & Jump to Definition broken in my Xcode 3 Project
提问by Jimmy
My project was created in Xcode 3, I'm opening it in Xcode 4 and notice the following:
我的项目是在 Xcode 3 中创建的,我在 Xcode 4 中打开它并注意以下几点:
- '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!)
- “跳转到定义”不再适用于我自己的符号(但是 UI* 甚至 TT* 符号确实可以正常工作!)
- 自动完成/“代码感知”与 Xcode 3 一样糟糕,也就是说,它暗示了一切
- 我的项目的课程没有出现在课程导航器中(同样,系统和 Three20 课程确实出现了!)
When creating a newXcode 4 project however, these features doseem to work. Unfortunately the only workaround seems to be to recreate the project and re-import everything. This project is too large!
但是,在创建新的Xcode 4 项目时,这些功能似乎确实有效。不幸的是,唯一的解决方法似乎是重新创建项目并重新导入所有内容。这个项目太大了!
Things I've tried:
我尝试过的事情:
- Removing the derived data in the organiser
- Cleaning the project
- Installing both Xcode 4 Gold Master and Final versions
- 删除管理器中的派生数据
- 清理项目
- 安装 Xcode 4 Gold Master 和 Final 版本
Update
更新
- This bug has notbeen resolved in Xcode 4.0.1.
- 此错误已不是在Xcode 4.0.1得到解决。
采纳答案by Maria Zverina
In our case the culprit turned out to be old version of the three20 libs. To get the project working I had to:
在我们的例子中,罪魁祸首是旧版本的 Three20 库。为了让项目工作,我必须:
- Remove all references to three20 from the project
- Follow the instructions at http://three20.info/article/2011-03-10-Xcode4-Support
- 从项目中删除对three20的所有引用
- 按照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! :)
安装新库后,xcode4 会自动重新索引。代码完成、跳转到定义甚至重构现在都可以工作了。使用 Xcode 的喜悦 (tm) 又回来了!:)
In more general terms, any library that puts it header files into BUILT_PRODUCT_DIR is likely to have similar issues.
更笼统地说,任何将头文件放入 BUILT_PRODUCT_DIR 的库都可能有类似的问题。
回答by xhan
On WindowMenu:
在窗口菜单上:
- Organizer
- Projects tab
- Your Project
- Delete Derived Data
- Restart Xcode
- 组织者
- 项目选项卡
- 你的项目
- 删除派生数据
- 重启Xcode
A little tip from other's answer:
来自其他人的回答的一点提示:
After step.4 don't rebuild the project but just restart Xcode.
在 step.4 之后不要重建项目而只是重新启动 Xcode。
回答by yeahdixon
What worked for me when i lost xcodes super nice code hinting was:
当我丢失 xcodes 超级好的代码提示时,对我有用的是:
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.
但!!!!!在这一步不要重建而是关闭 xcode 并重新打开项目。这对我有用。
回答by gstroup
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.
我今天在 XCode 4 最终版本中遇到了同样的问题,使用我的旧 XCode 3 项目。该问题与 XCode 创建的符号索引有关。它应该会自动为您创建一个新索引,但在 XCode 4 中似乎需要很长时间。一种可能的解决方案是转到 ~/Library/Developer/Xcode/DerivedData 并删除旧索引。重新启动 XCode,您应该会看到它正在索引。对于“跳转到定义”,您可以按住命令并将鼠标悬停在方法或类名称上,您应该会看到蓝色下划线,如超链接。然后你可以点击它跳转到定义。
回答by Rick
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.
编辑:似乎如果您有任何自定义标头搜索路径来支持具有共享代码的多个目标,XCode 4 索引将中断,然后助手和代码感也会随之中断。我已经向 Apple 提出了 #ID 9182099。还有一个问题是,如果项目全局和目标特定构建设置之间存在任何冲突设置,索引将无法正确完成。确保您的构建设置一致。
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.
我刚刚在一个非常大的多目标商业项目中遇到了这个问题。作为额外的痛苦,所有的 xib 文件都不会在助手视图中显示控制器,并且子类/超类/兄弟姐妹/类别助手视图也不会工作。
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.
为了实现这一点,我创建了一个新的“空”项目,然后手动重新创建了我需要的目标。然后我删除了新目标的源文件和 .plist 文件,再次留下一个包含我需要的三个目标的空项目。
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.
然后我只选择“添加文件..”到项目一个文件夹,根据需要链接到目标。我停止并构建了每个目标,因为它被导入以处理最新的 clang 给我的任何编译器错误。
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.
如果您有一个未映射到文件系统文件夹结构的复杂组层次结构,那么您要么需要在导入后重新创建组,要么经历将所有文件移动到子文件夹并在 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.
您还需要仔细检查目标中的任何自定义构建设置,并重新链接您包含的任何库。还要确保从目标链接中删除任何批量导入的 .plist 文件。
Sorry if this is not the answer you had hoped for.
抱歉,如果这不是您希望的答案。
回答by GreatWiz
http://three20.info/article/2011-03-10-Xcode4-Supportworked 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.
http://three20.info/article/2011-03-10-Xcode4-Support对我来说有效。具体擦除了three20的Build目录。奇怪的是,即使上述构建是在 xcode4 中进行的,它也能工作。CodeSense 在我删除了 Three20 构建目录的那一刻开始工作,我什至不需要重新编译或重新加载项目。
回答by Christopher Rogers
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.
- 打开您的 Xcode 项目。
在您的项目目录中打开命令提示符并键入:
touch MyProject.xcodeproj/project.pbxproj
看着语法着色和其他东西在您眼前得到修复。
- 如果您的项目方案被重置为 iOS 项目的“我的 Mac”,请重新打开您的项目(或调整项目设置)。
回答by k3a
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.
我通过删除 th Organizer 中的派生数据、运行touch MyProject.xcodeproj/project.pbxproj
并重新打开项目来解决该问题。重新打开后,它开始编制索引,然后又开始工作了。
回答by Eric Goldberg
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.
在几个地方也添加了这个作为评论,所以也许谷歌果汁会帮助程序员重新启动和运行......但无论如何,我发现如果你只是touch
在YourAppName-Prefix.pch
文件上使用命令它会得到语法高亮/着色和代码完成/重新跳转而无需删除所有派生数据或重新启动 Xcode。我在我的 .bashrc 文件中将此作为别名。
alias pch_touch='touch /path/to/your/apps/Prefix.pch'
alias pch_touch='touch /path/to/your/apps/Prefix.pch'
. ~/.bashrc
. ~/.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.
在触摸 pch 文件大约 1-2 秒内,语法着色又回来了,这是一个符号代码完成/跳转现在也将起作用。有点可悲的是,这样一个否则很棒的强大工具被一些元数据/状态错误所削弱,但是你去了。至少它可以让您重新启动并运行并停止浪费您的时间。
回答by Duane Fields
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.
在我的 XCode 4 设置中,设置用户标题搜索路径会在重新启动后破坏代码感知,尤其是“跳转到定义”,这一点是 100% 可重现的。我创建了一个新项目,将我的助手库添加为子项目。如果我在用户标题搜索路径(递归)中包含标题,我可以编译,但自动完成/导航被破坏。
Deleting the header search path, closing the project, and reopening, fixes it again.
删除标题搜索路径,关闭项目,重新打开,再次修复。