1
votes

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.

enter image description here

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.

4
I had an issue with the Custom Class dropdown as well a few weeks ago: stackoverflow.com/questions/29504634/… - Dan Beaulieu
@DanBeaulieu: Trying with a different is not the solution. - Ajay
Did I say it was the solution? I just said I had a similar problem and described how I got around it. - Dan Beaulieu
Ok got it. Plz suggest if you have any other workaround. - Ajay

4 Answers

6
votes

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">
2
votes

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.

0
votes

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.

0
votes

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];