Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unknown class in interface builder

I know that there are a lot of questions on this subject but I've tried most of them to try and figure it out with no success.

the problem: at first I couldn't add my class from the assistant editor cause the custom class didn't pick it up.

  1. I made sure the calls inherits from uiviewcontroller
  2. I made sure the class is added to the target
  3. I tried to remove the class file and re-add it back
  4. finally I've added the class through the storyboard xml and it appeared in the custom class

Now I'm trying to connect my buttons, views etc to its outlets. It seems like they are connected but when running the app and opening that view controller the app crashes and the debugger prints: "Unknown class xxx in Interface Builder file." and than "this class is not key value coding-compliant for the key btnMenu."

I've checked:

  1. That connection inspector is properly set (no error in the outlets there)
  2. Tried to delete derived data
  3. Clean project
  4. Re-install the app

I even tried restarting my mac and of course no success.

can anyone shad some light here? thanks.

like image 490
Max Avatar asked Aug 09 '16 09:08

Max


2 Answers

I just had this happen with a UIViewController subclass (with Xcode 9 beta 2 & Swift 4) and the solution was to tick 'Inherit from Target' where I set the Custom Class in IB.

If your view happens to be in a .bundle file (such as for a framework/static library) that gets copied to a different target, you'll want to set an explicit module target for each xib/storyboard class rather than having it inherit from the target that's hosting it.

like image 92
Anthony Scott Avatar answered Oct 05 '22 18:10

Anthony Scott


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 on the interface builder. This Helped in my case.

enter image description here

like image 22
dmaulikr Avatar answered Oct 05 '22 17:10

dmaulikr