Xcode 6 Bug: Unknown class in Interface Builder fi

2018-12-31 16:33发布

I upgraded to Xcode 6 beta 4 and now my App continuously crashes with the message

Unknown class X in Interface Builder file.

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.

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.

30条回答
无与为乐者.
2楼-- · 2018-12-31 17:00

I faced this problem in Xcode 8, to resolve it I had to modify storyboard in the text editor.

In general, look up for your control and remove customModule and customModuleProvider from control entity.

Did a trick for me.

查看更多
不流泪的眼
3楼-- · 2018-12-31 17:00

The solution was different for me. You need to add the .m of the class to the build phase compiled sources of the target.

Hope this helps!

查看更多
泛滥B
4楼-- · 2018-12-31 17:01

This can happen in any Xcode above 6.0. It happened to me after renaming some ViewController classes in Swift project (but I guess it will happen with Obj-C too). You just have to open the interface builder, go to Identity Inspector of ViewController that had its class renamed, select class and press Enter. That will reassign renamed class to selected ViewController and also reset Module Value which gets lost after renaming the class.

Update for Xcode 8.1 (probably 8.0 too):

Xcode 8.1 just crashes. Simply and annoyingly just crashes and doesn't print anything. I was chasing that phantom crash for an hour just to find out that it was this very same thing - unassigned class in IB. If you're getting some phantom crashes, double check IB for unassigned classes first.

查看更多
骚的不知所云
5楼-- · 2018-12-31 17:01

Check if your class has right Target Membership.

查看更多
梦寄多情
6楼-- · 2018-12-31 17:01

What @gfrs said is correct, you need to set the Module. However I once ran into an issue that my class wasn't listed in the Class dropdown. Eventually I removed the swift file, re-started Xcode and re-created the file. Finally the class was listed and could be used in Storyboard.

Also have a look at this answer, which looks like to solve the 'real' problem I encountered.

查看更多
笑指拈花
7楼-- · 2018-12-31 17:01

What only worked for me is actually adding the module name to the xib file...

Sooo, the xib files look like this:

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.

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."

查看更多
登录 后发表回答