Unknown class in interface builder

I know that there are many questions on this subject, but I tried most of them to try to understand this without success.

problem: at first I could not add my class from the editor assistant because the user class did not take it.

  • I made sure calls are inherited from uiviewcontroller
  • I made sure the class is added to the target
  • I tried deleting the class file and adding it back again
  • Finally, I added the class via the xml storyboard and appeared in a custom class

Now I'm trying to connect my buttons, views, etc. to your exits. They seem to be connected, but when you start the application and open this view controller, the application crashes and the debugger prints: Msgstr "Unknown class xxx in Interface Builder file." and then "this class is not a key code compatible for the btnMenu key."

I checked:

  • This inspector is connected correctly (there are no errors in the outputs)
  • Tried to delete derived data
  • Clear project
  • Reinstall the application

I even tried restarting my Mac and of course I couldn’t.

Can someone illuminate the light here? thanks.

+30
ios iphone xcode storyboard
source share
12 answers

I just did this with a subclass of UIViewController (with Xcode 9 beta 2 and Swift 4), and the solution was to check "Inherit from Target", where I set the custom class to IB.

If your view is in a .bundle file (for example, for a framework / static library) that is being copied to another target, you need to set an explicit module target for each xib / storyboard class, and not inherit it from the target that hosts it.

+81
source share

For me, the problem was that the class was not part of the target membership. Just add the class to the target, and you should see it back in the interface builder. It helped in my case.

enter image description here

+23
source share

After I checked the checkbox called "Inherit Module From Target" in the user class in the View Controller section, it works fine. You can follow the image.

To find this> Select the yellow view controller button >, then click " Show Identity Inspector ">, and then check the box named " Inherit module from target" "

enter image description here

+8
source share

What @Anthony Scott mentioned is true until you have a Framework_A dependent on Framework_B, and a class depends on Framework_B :) Then you need to uncheck the box and provide the Module that contains this class. Thanks for the question, by the way. I use the Commons framework for other frameworks, and it helped me understand this;) For those who develop custom Cocoa Touch frameworks, this can be useful.

+3
source share

If you are trying to assign a ViewController class, make sure that the class you create inherits from the UIViewController. The only reason xCode does not recognize your class is because it is a different type of instance, for example, it could be a type of UITableViewController.

First check the inheritance of your class.

+2
source share

I had this problem with a custom UIView that I tested where the UIView was in the framework. I created a simple application, created a UIView in the default StCboard ViewController, and set its class to MyCustomView. I always got the error "Unknown class in the interface designer" when starting the application. I imported my framework and checked in the assembled product that the framework was there.

The problem was that the code of my test application never used this environment. Although the Storyboard referenced it, I think it never booted. When I added [MyCustomView load]; into the code of the test application, it all worked.

+2
source share

ok, so I don’t know how and why, but I did (AGAIN) what I already tried before:

  • class deletion
  • creating the same class with a new name
  • deleted the scene and recreated it in the storyboard
  • knit everything (in the same way !!!)

now it seems that Xcode knows my class .... I still don't know what the problem is, but I think this has something to do with the linker.

+1
source share

I ran into this error because I accidentally saved my class file to the Base.lproj folder when I created it.

I fixed the error by right-clicking the file in the Project Navigator and deleting the link to it. Then I moved the file through the Finder to the desired folder. Then I right-clicked the main group in the Project Navigator and clicked " Add Files to "GroupName"... selected the class and clicked the" Add .

After that, the error went away.

+1
source share

Check the name of your class. Make sure it matches the class you assigned the ViewController in the Property inspector.

0
source share

You need to create an instance of the view controller using a custom class. Without this, an error may occur.

 self.storyboard!.instantiateViewController(withIdentifier: "namePage") as! EmailAndPassword 
0
source share

none of this helped. My problem was that I created my own storyboards and added my own classes. But I forgot to take the initial controller’s arrow from the automatically generated main storyboard and replaced the original storyboard with my own storyboard, which fixed it for me.

0
source share

For those who are facing this problem, but with a system class like PKCanvasView or ARView in the storyboard.

After you customize the Custom Class view to any of these system classes, make sure Module set to None . Then go to the Link Binary with Libraries target in Build Phases and manually bind the structure that contains this class. The last step is to clear and delete the derived data (this is important, otherwise the problem will not disappear).

0
source share

All Articles