简体   繁体   English

Xcode Swift自动完成失败&lt; <error type> &gt;

[英]Xcode Swift Autocomplete Failure <<error type>>

When declaring an outlet, the AutoCompleter outputs "error type". 声明出口时,自动完成器将输出“错误类型”。 The outlet also loses properties. 出口也失去了特性。 Deleting derived data and some files in Xcode project's packet did not help. 删除Xcode项目数据包中的派生数据和某些文件无济于事。

Example: 例:

example

To avoid this issue you should to update the project's cash which Xcode generates for every project. 为避免此问题,您应该更新Xcode为每个项目生成的项目现金。 To do that, go to 为此,请转到

/Users/UserName/Library/Developer/Xcode/DerivedData /用户/用户名/库/开发商/ Xcode中/ DerivedData

directory and remove 目录并删除

ModuleCache ModuleCache

directory from there. 目录从那里。

After you do that, quit from Xcode and open your project again. 完成之后,退出Xcode并再次打开您的项目。 Xcode will rebuild project index and error should be out. Xcode将重建项目索引,错误应该排除。

You should also ensure that the class you are having an issue autocompleting is listed in the "Compile Sources" build phase for your target. 您还应确保在目标的“编译源”构建阶段中列出了发生自动填充问题的类。 I've had several occasions where source files mysteriously disappear - with the same result you are seeing. 我曾经有几次神秘地消失源文件-与您看到的结果相同。

An Xcode restart fixed this problem for me. Xcode重新启动为我解决了此问题。

I had a very similar problem. 我有一个非常类似的问题。 When I used dot.notation to drill into a Class Instance I created, the autofill did not recognize the types for each property. 当我使用dot.notation深入研究我创建的类实例时,自动填充无法识别每个属性的类型。 The class property in question was explicitly defined as a String? 有问题的类属性已明确定义为String? [Optional] Type. [可选]类型。

I expected the autofill to show that: 我希望自动填充可以显示以下内容:

myInstance.name is of type "String?"

but the autofill said that: 但是自动填充说:

myInstance.name is of type "error".  This appeared:  "<< error type >>"

A restart of Xcode, to my surprise, fixed the problem. 令我惊讶的是,重新启动Xcode可以解决此问题。

Maybe, the restart effectively did the "resetting" techniques others posted here. 也许,重启实际上有效地实现了其他发布在此处的“重置”技术。 Looks like a performance or refresh issue on Xcode's part. 看起来Xcode的性能或刷新问题。 Things running smoothly now. 现在事情进展顺利。

Note: If you can reference your class fine in other places the file where you call the "error" class is the issue, not the "error" class itself. 注意:如果可以在其他地方很好地引用类,则称为“错误”类的文件就是问题所在,而不是“错误”类本身。 The only thing that works for me is deleting (removing reference) the file that references the "error" class and adding the file back to the project. 对我唯一有效的方法是删除(删除引用)引用“错误”类的文件,并将该文件添加回项目中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM