Xcode 4 代码感知不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5431501/
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 code sense is not working
提问by Okku
I am running a "old" Xcode 3 project in Xcode 4 and code sense is not working for my own classes. I have tried following:
我正在 Xcode 4 中运行一个“旧”的 Xcode 3 项目,并且代码意识不适用于我自己的类。我试过以下:
- Clean/rebuild
- Remove Derived Data
- Installing 4.3 documentation
- Restart
- 清理/重建
- 删除派生数据
- 安装 4.3 文档
- 重新开始
Without any luck.
没有任何运气。
Sometimes the code sense works but mostly I just get "No Completions".
有时代码意义有效,但大多数情况下我只是得到“没有完成”。
回答by Saikat
Try this:
尝试这个:
Open Organizer then Project Tab.
打开管理器,然后打开项目选项卡。
Clear the "Derived Data". Xcode should re-index your project then and code sense should work. At least worked for me.
清除“派生数据”。Xcode 应该重新索引你的项目,代码感知应该可以工作。至少对我有用。
回答by Chris Burt-Brown
I know this is late, but for reference: http://sealedabstract.com/code/when-xcode-4s-code-completion-autocomplete-breaks/
我知道这已经晚了,但仅供参考:http: //sealedabstract.com/code/when-xcode-4s-code-completion-autocomplete-breaks/
Close the project, leaving XCode still running.
Open XCode's Organizer window, go to the Projects Tab, select the correct project, and hit the Delete button next to “Derived Data”.
Quit XCode.
Navigate to your project's .xcodeproject file in Finder. Right-click, choose “Show Package Contents.”
Leave the project.pbxproj file, but delete the project.xcworkspace file, any .pbxuser files, and the entire userdata folder.
Open the project in XCode. You will see XCode riding high on the CPU usage for around 10-60 seconds, depending on the size of your project. The activity window will say “Indexing”
When your CPU spike returns to earth, code completion will be working again.
关闭项目,让 XCode 仍在运行。
打开 XCode 的管理器窗口,转到项目选项卡,选择正确的项目,然后点击“派生数据”旁边的删除按钮。
退出 XCode。
在 Finder 中导航到项目的 .xcodeproject 文件。右键单击,选择“显示包内容”。
保留 project.pbxproj 文件,但删除 project.xcworkspace 文件、任何 .pbxuser 文件和整个 userdata 文件夹。
在 XCode 中打开项目。根据项目的大小,您将看到 XCode 在 CPU 使用率上居高不下大约 10-60 秒。活动窗口将显示“索引”
当您的 CPU 峰值返回地球时,代码完成将再次工作。
There's a lot of deleting going on there so please be careful, but this definitely worked for me.
那里有很多删除内容,所以请小心,但这绝对对我有用。
回答by Stephen J
I've been doing this, and it's worked multiple times for me (after trying all of the above previously).
我一直在这样做,并且它对我有用过多次(在之前尝试过上述所有方法之后)。
Edit: Now I just hit space, backspace (the mac version) and rebuild... works nice. Then, remember to scroll (sometimes the colors don't show up until you scroll somewhere)
编辑:现在我只是按空格键,退格键(mac 版本)并重建......效果很好。然后,记得滚动(有时直到你滚动到某个地方才会显示颜色)
- Find your prefix file: "ProjectName_prefix.pch".
- Comment out some line. (basically change it)
- Build your project, doesn't matter if it fails or not.
- Uncomment it.
- Build again.
- 找到您的前缀文件:“ProjectName_prefix.pch”。
- 注释掉一些行。(基本上改变它)
- 构建你的项目,不管它是否失败。
- 取消注释。
- 再建。
I'm betting only step 2 (modify the prefix) is what does it, but these essentially get you back to running. Suddenly everything magically recolors itself and completes functions.
我打赌只有第 2 步(修改前缀)是做什么的,但是这些基本上可以让您重新开始运行。突然间,一切都神奇地重新着色并完成了功能。
Good luck if that doesn't fix it, perhaps try doing this to your dependency pch files (three20 or FB api's)
如果这不能解决它,祝你好运,也许尝试对您的依赖 pch 文件(three20 或 FB api)执行此操作
回答by Hlung
Clearing the "Derived Data" only works temporarily for me. I have to do it and then restart Xcode like 3-4 times each day to get code sense working again.
清除“派生数据”仅对我有用。我必须这样做,然后每天重新启动 Xcode 3-4 次,以使代码感知再次工作。
I found out the real cause is in the Target'sBuild Settings. I moved everything from Header Search Pathsto User Header Search Pathsand it is fixed. In my case, the framework I'm working with is RestKit.
我发现真正的原因是在目标的构建设置中。我将所有内容从标题搜索路径移动到用户标题搜索路径,并且已修复。就我而言,我正在使用的框架是 RestKit。
BTW, I came up with this because I was adding another project (QuickDialog) into my project and I was curious that it is using User Header Search Paths, but not Header Search Paths. Here is the difference between them.
顺便说一句,我想出这个是因为我在我的项目中添加了另一个项目(QuickDialog),我很好奇它使用的是User Header Search Paths,而不是Header Search Paths。这是它们之间的区别。
回答by gowrikarthick
You can able to fix that issue by change build settings like this, PreCompile Prefix Headers :NO
您可以通过更改这样的构建设置来解决该问题,PreCompile Prefix Headers :NO
回答by zekel
FYI, if one file doesn't have code sense but the rest of your project does, check that its added to a target. Once I did that I got code sense back in that file.
仅供参考,如果一个文件没有代码意义但项目的其余部分有,请检查它是否已添加到目标中。一旦我这样做了,我就在那个文件中恢复了代码意识。
回答by Saad
Close all xcode windows
Delete all your projects from xcode>window>organizer and restart your project. It will now sense and index your project properly.
关闭所有 xcode 窗口
从 xcode>window>organizer 中删除所有项目并重新启动项目。它现在将正确感知和索引您的项目。
回答by Bahamut
It's been ages but the answer is just to move the code into a new folder and the code sense should be working now.
已经有很长时间了,但答案只是将代码移动到一个新文件夹中,代码意识现在应该可以工作了。
This happened when I added a new Objective-C Class and the code sense doesn't work only on the newly added .m and .h files (on XCode 4 latest update during this post).
当我添加一个新的 Objective-C 类时发生了这种情况,并且代码意义不仅仅适用于新添加的 .m 和 .h 文件(在这篇文章中的 XCode 4 最新更新上)。
回答by zakishaheen
I wrote about it in detail here.
我在这里详细描述了它。
Basically my fix was that with localization. I upgraded from xcode 3.2.5 to xcode 4 and then screwed around with built in interface builder and turned on localization for a XIB file accidently which placed my source files in en.lproj directory. After moving them back to Classes folder it worked perfectly.
基本上我的解决方法是本地化。我从 xcode 3.2.5 升级到 xcode 4,然后用内置的界面构建器搞砸了,并意外地打开了 XIB 文件的本地化,将我的源文件放在 en.lproj 目录中。将它们移回 Classes 文件夹后,它运行良好。
回答by newDeveloper
I open a second project in the background whenever my Xcode's code sensing stops working (it usually works the first time i open the project but after a while code sense no longer works). So what i do is to open a second project in Xcode. Xcode will start indexing the second project and magically the code sense for my main project is back.
每当我的 Xcode 的代码感知停止工作时,我都会在后台打开第二个项目(它通常在我第一次打开项目时起作用,但一段时间后代码感知不再起作用)。所以我要做的是在 Xcode 中打开第二个项目。Xcode 将开始为第二个项目建立索引,我的主项目的代码意义神奇地又回来了。
Running Xcode 4.3.1 on Lion
在 Lion 上运行 Xcode 4.3.1
Hope this helps someone.
希望这可以帮助某人。