Xcode 8.2 代码补全不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41227787/
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 8.2 Code Completion Not Working
提问by ethanfox27
For some reason, in Xcode 8.2 my code completion has stopped working. I have cleaned my product, restarted Xcode, restarted my computer, and deleted the derived data, and still no luck. I have submitted this to Apple Support. Has anyone run into this before and been able to fix it?
出于某种原因,在 Xcode 8.2 中,我的代码完成已停止工作。我已经清理了我的产品,重新启动了 Xcode,重新启动了我的计算机,并删除了派生数据,但仍然没有运气。我已将此提交给 Apple 支持。有没有人遇到过这个问题并且能够修复它?
采纳答案by charles
Code completion also stopped working for me in Xcode 8.2.1, and no amount of clean-up, derived data throwaway or restart fixed it. After a while, I realized code completion was only broken within the extension scope I was working on. If typed manually, the code would be correctly highlighted and would compile fine, so it was not an issue of the source throwing off whatever parser is in charge of code completion.
代码完成在 Xcode 8.2.1 中也停止对我来说有效,并且没有任何清理、派生数据丢弃或重新启动修复它。过了一会儿,我意识到代码完成只在我正在处理的扩展范围内被破坏。如果手动输入,代码将被正确突出显示并且可以正常编译,因此源代码不会抛弃负责代码完成的任何解析器。
Here is the specific context in which it happens, in this very simple example:
这是它发生的具体上下文,在这个非常简单的例子中:
struct SomeStruct {
static let foobar1 = {
return NSBezierPath()
}()
}
extension SomeStruct {
static let foobar2 = {
return NSBezierPath()
}()
}
Code completion works fine within the implementation block of foobar1
, but not for foobar2
. It's the presence of a static let
within an extension that seems to trigger it. The issue appears for both struct and class.
代码完成在 的实现块内工作正常foobar1
,但不适用于foobar2
。static let
似乎是在扩展中存在 a来触发它。结构和类都会出现此问题。
Looks like a bug with Xcode, so the only workaround for me was to move foobar2
into the main definition of SomeStruct
.
看起来像 Xcode 的一个错误,所以对我来说唯一的解决方法是foobar2
进入SomeStruct
.
回答by Chinmay
Update:As per @Dareon solution below also works for Xcode Version 8.3 (8E162) and 8.3.2 (8E2002). Thanks, @Dareon for the confirmation. :)
更新:根据下面的@Dareon 解决方案也适用于 Xcode 版本 8.3 (8E162) 和 8.3.2 (8E2002)。谢谢,@Dareon 的确认。:)
I was facing the same issue and following worked for me.
我面临同样的问题,以下对我有用。
I am using Xcode Version 8.2.1 (8C1002).
我正在使用 Xcode 版本 8.2.1 (8C1002)。
- Go to Xcode > Preferences > Text Editing
- Under Code completion - Uncheck 'Suggest completions while typing'
- Quit out of Xcode and then relaunch Xcode.
- Go to Xcode > Preferences > Text Editingagain
- Quit out of Xcode and then relaunch Xcode.
- Now go to Code completion and check'Suggest completions while typing'.
- Try typing library function or enum and enjoy!
- 转到Xcode > 首选项 > 文本编辑
- 在代码完成下 - 取消选中“键入时建议完成”
- 退出 Xcode,然后重新启动 Xcode。
- 再次转到Xcode > Preferences > Text Editing
- 退出 Xcode,然后重新启动 Xcode。
- 现在转到代码完成并选中“键入时建议完成”。
- 尝试输入库函数或枚举并享受!
At least, it worked for me.
至少,它对我有用。
回答by catanore
Just restarting Xcode worked for me.
只是重新启动 Xcode 对我有用。
回答by Rein rPavi
Just clean and build your app once on Generic iOS Device
, it might be due to some compile time issue, which disables the intelligence, I am seeing this bug since Xcode 8.2.1.
只需清理并构建您的应用程序Generic iOS Device
,这可能是由于一些编译时问题,这会禁用智能,我从 Xcode 8.2.1 开始看到这个错误。
回答by user1105951
What worked for me was deleting derived data:
对我有用的是删除派生数据:
Xcode Preferences -> Locations -> arrow symbol takes you to "Derived Data" -> delete folder
Xcode 首选项 -> 位置 -> 箭头符号将您带到“派生数据”-> 删除文件夹
回答by bdepaz
I have had major issues with this as well. For me the code completion and formatting gets lost on my current working source file when ever I do a compile. If I go back and switch to a different tab and come back, after a second or two it starts working again. Sometimes even that doesn't work and I have to stay in the same tab and open up a different file and then navigate back.
我也遇到了重大问题。对我来说,当我进行编译时,代码完成和格式化会在我当前工作的源文件中丢失。如果我返回并切换到不同的选项卡并返回,一两秒钟后它会再次开始工作。有时即使这样也行不通,我必须留在同一个选项卡中并打开一个不同的文件,然后返回。
Even those methods fail if I leave Xcode open and put the computer to sleep for a few hours and come back. When that happens I have to quit Xcode, sometimes Force Quit it, and then after getting back in do the steps above. But I have had to mess around with it after every single compile or compile and run I do. Haven't tried 8.3 beta yet.
如果我让 Xcode 打开并使计算机休眠几个小时然后再回来,即使这些方法也会失败。发生这种情况时,我必须退出 Xcode,有时强制退出它,然后在返回后执行上述步骤。但是在每次编译或编译并运行之后,我都不得不弄乱它。还没试过 8.3 测试版。
回答by Karen Lusinyan
I had the same issue where the "indexing" did not work. As I was using a pod and static libraries. What I did just rebuild the static libraries separately.
我遇到了“索引”不起作用的相同问题。因为我使用的是 pod 和静态库。我所做的只是分别重建静态库。
Hope this helps.
希望这可以帮助。
回答by Eden
If you have any large static literals, try commenting them out. Those can sometimes trip up the compiler.
如果您有任何大型静态文字,请尝试将它们注释掉。这些有时会绊倒编译器。
回答by Matt Channon
Nothing else worked for me, but this bizarre approach did:
没有其他方法对我有用,但这种奇怪的方法确实做到了:
- Quit Xcode
- Go into your home directory, which if you're like me, is riddled with empty directories with garbage names
- rmdir * (as long as you leave the tags off, this will kill only empty directories, which is what you want)
- Launch Xcode, happy times again
- 退出 Xcode
- 进入你的主目录,如果你像我一样,里面充斥着带有垃圾名称的空目录
- rmdir * (只要你关闭标签,这只会杀死空目录,这就是你想要的)
- 启动Xcode,再次快乐时光