Xcode 6 Bug:Interface Builder文件中的未知类

本文翻译自:Xcode 6 Bug: Unknown class in Interface Builder file

I upgraded to Xcode 6 beta 4 and now my App continuously crashes with the message 我升级到Xcode 6 beta 4,现在我的应用程序不断崩溃

Unknown class X in Interface Builder file. Interface Builder文件中的未知类X.

It crashes because supposedly Xcode can't find my custom classes that I have linked in my Storyboard but it shows that they are linked correctly in the Xcode interface. 它崩溃了,因为据说Xcode找不到我在Storyboard中链接的自定义类,但它显示它们在Xcode界面中正确链接。

I'm positive everything is linked correctly. 我很肯定一切都是正确的。 My only other option may be to delete the entire storyboard file and start from scratch because it might be corrupted somehow. 我唯一的另一个选择可能是删除整个故事板文件并从头开始,因为它可能会以某种方式损坏。

Edit: I would also like to add that I tried cleaning, reseting simulator, messing with build phases etc. None of that works. 编辑:我还想补充一点,我尝试清理,重置模拟器,弄乱构建阶段等。这些都不起作用。


#1楼

参考:https://stackoom.com/question/1ga7a/Xcode-Bug-Interface-Builder文件中的未知类


#2楼

I resolved this issue as I was typing the question. 当我输入问题时,我解决了这个问题。 I figured I'd answer my question and leave it here for anyone else who may face this issue when using Xcode 6 beta 4. 我想我会回答我的问题,并将其留给其他可能在使用Xcode 6 beta 4时遇到此问题的人。

To resolve this issue, you need to select each of your custom class objects in Storyboard (this includes any custom views, even the custom view controllers themselves). 要解决此问题,您需要在Storyboard中选择每个自定义类对象(这包括任何自定义视图,甚至是自定义视图控制器本身)。

Then with those objects selected, open the identity inspector and under "Custom Class" you should see the Module option. 然后选择这些对象,打开身份检查器,在“自定义类”下,您应该看到“模块”选项。 Click inside the Module text box, and press enter. 在“模块”文本框内单击,然后按Enter键。

That's it! 而已! The current module for all of my custom objects must have been internally incorrectly set somehow in Xcode 6 beta 4. But there was no visual indication of this in the inspector. 我的所有自定义对象的当前模块必须在Xcode 6 beta 4中以某种方式在内部错误设置。但是在检查器中没有这种可视指示。

Note that if pressing enter inside the Module text box doesn't work, try selecting the arrow to the right and manually select your current module, then clear the text box and press enter. 请注意,如果在“模块”文本框内按Enter键不起作用,请尝试选择右侧的箭头并手动选择当前模块,然后清除文本框并按Enter键。 You can also try pressing enter inside the class text box (although this usually is to resolve a different issue). 您也可以尝试在类文本框中按Enter键(尽管这通常是为了解决另一个问题)。

Here is an image to make things more clear: 这是一个让事情变得更清晰的图像: 在此输入图像描述


#3楼

What @gfrs said is correct, you need to set the Module. @gfrs说的是正确的,你需要设置模块。 However I once ran into an issue that my class wasn't listed in the Class dropdown. 但是,我曾经遇到过一个问题,即我的课程没有在Class下拉列表中列出。 Eventually I removed the swift file, re-started Xcode and re-created the file. 最后我删除了swift文件,重新启动了Xcode并重新创建了该文件。 Finally the class was listed and could be used in Storyboard. 最后列出了类,可以在Storyboard中使用。

Also have a look at this answer , which looks like to solve the 'real' problem I encountered. 还看看这个答案 ,看起来像是解决了我遇到的'真实'问题。


#4楼

What only worked for me is actually adding the module name to the xib file... 实际上只对我有用的是将模块名称添加到xib文件中......

Sooo, the xib files look like this: Sooo,xib文件如下所示:

mymodule.MyViewController.xib (Module being the name of the proyect, usually)

HORRIBLE solution in my opinion, but that is supposedly how Apple wants us to do it now. 在我看来,这是一个可怕的解决方案,但这应该是Apple希望我们现在这样做的方式。

This question shows 3 possible work arounds back in beta 4 ... apparently Apple has not been very helpful in this situation according to some because they call it "Working as intended." 这个问题显示了3个可能在beta 4中可能的工作 ......显然Apple在这种情况下并不是很有帮助,因为他们称之为“按预期工作”。


#5楼

I had this problem after renaming a swift class. 重命名swift类后我遇到了这个问题。 Solved it by using the @objc directive: 使用@objc指令解决了这个问题:

@objc(ForumTopicListViewController) class ForumTopicListViewController

#6楼

I had the same problem with Xcode Version 6.1 (6A1052d). 我对Xcode Version 6.1(6A1052d)也有同样的问题。 I think the problem appears if you renamed your App / Xcode Project. 我认为如果您重命名App / Xcode项目会出现问题。

My solution was to add the module name in the interface builder manually. 我的解决方案是手动在界面构建器中添加模块名称。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值