简体   繁体   中英

XCode 6.3 bug: Unknown class in Interface Builder file

I am working with XCode 6.3 & Swift.

I have just added a few view controllers in my storyboard & added the custom classes & set the respective custom classes in identity inspector.

在此处输入图片说明

But while I run the app it shows Unknown class X in Interface Builder file. & I am not able to interact with my custom classes. There are few similar questions like this & I have tried all the solutions but none of them are working for me.

Sometimes Xcode missed customModule="AppName" customModuleProvider="target"

To fix it, open storyboard as source code and replace this line:

<viewController storyboardIdentifier="StoryboardId" id="SomeID"   customClass="CustomClass"
sceneMemberID="viewController">

to this:

<viewController storyboardIdentifier="StoryboardId" id="SomeID" customClass="CustomClass"
customModule="AppName" customModuleProvider="target" sceneMemberID="viewController">

All my viewControllers were ok, but I searched through he whole storyboard file and found this:

<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC" customClass="end">

Removing the custom class got rid of the error:

<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">

No idea why this custom class was there in the first place.

I restarted my Macbook and all modules started to populate in the Custom Class box. No created classes were showing in the dropdown box.

I'm on Xcode 7.0.1, OSX 10.10.5 on a 2015 Macbook Pro. That was a really annoying error to figure out.

It may seem like a tedious thing but make sure that everywhere you have referenced the view controller it has been spelled correctly. I regrettably spent a lot of time attempting all of the suggestions to fix the error and it turned out to be a simple spelling mistake!

Before:

UIViewController *myViewController = [[FormApplicationViewController alloc] initWithNibName:@"FormApplicationviewController" bundle:nil];

After:

UIViewController *myViewController = [[FormApplicationViewController alloc] initWithNibName:@"FormApplicationViewController" bundle:nil];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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