"Unknown class <MyClass> in Interface Builder file" error at runtime

Viewed 173574

Even though Interface Builder is aware of a MyClass, I get an error when starting the application.

This happens when MyClass is part of a library, and does not happen if I compile the class directly in the application target.

46 Answers

In my case it was showing an error for a class that didn't even exist! I suspected it was something that got borked in the storyboard file. If you don't recognize the class file in the error try this:

1) open your project in sublime or another good editor. Search for the class being referred to. 2) remove the whole bit that says

customClass="UnrecognizedClassName"

3) save it. 4) return to xcode and clean the project, and try running it now.

worked for me.

enter image description here

This problem does not seem to get outdated.

I had the same issue with Xcode 8 and solved it similiar like smilebot:

  1. Open your storyboard file as "Source code" within Xcode:

  2. Search for the class being referred to & remove the whole bit that says

customClass="UnrecognizedClassName"

  1. Open your storyboard file as "interfacebuilder - storyboard" again and rebuild your app.

In my case it was because I declared a subclass of a subclass of a UITableView cell in the .h file (the declaration of both subclasses were in the same .h file), but forgot to make an empty implementation of that second subclass in the .m file.

don't forget to implement any subclass of a subclass you declare in the .h file! sounds simple, but easy to forget because Xcode will do this for you if you are working with one class per .h/.m file.

In my case, the class couldn't be found because it was a classed defined in an extension inside the framework like so:

extension Buttons {
    public class MyButton: UIButton {
        // ...
    }
}

When I extracted the class from the extension, the Storyboard could finally find the class (MyFrameworkButton):

extension Buttons {
    public typealias MyButton = MyFrameworkButton
}

public class MyFrameworkButton: UIButton {
    // ...
}
Related