markneustadt.com

Unknown class “class name” in Interface Builder file.

Wow… just… wow.  This took a long time to figure out.  I was trying to create and use a custom UIButton in an iOS project.  Everytime I tried it, the app would open and immediately close.  Typical crash behavior.

As is the norm, I opened the console.  This is my first step in trying to figure out what the heck is going on.

So after I opened the console, I built the application and ran it.

That’s where I found it.  The root cause of my error.

Unknown class MATCGlossyButton in Interface Builder file.

Hmmm…. what does this mean?  I opened Interface Builder and checked things out there.  Everything looked good.  My button had the right class name defined so Interface Builder knows about the class.

Time to do some searching… I fire up the old Google Search to see what’s what.  I found a lot of hits referring to the linker not including the custom class (in my case MATCGlossyButton) in the compiled code for some reason.  There were several hits referring to changing a few compiler settings.  Adding these settings, apparently, would solve my problems.

Okay… settings added.  Error persists.

Hit after hit refers to those settings.  Some hits refer to modifying the settings in the target as well but I found that when I looked at the settings for the target, it was already set that way.

Again, I think about the root cause… the class isn’t being included in the compiled code.  The target…  Hmm….

I investigated the target a bit and found something interesting.

I see all the source code I expect.  Wait… no I don’t!  Where’s the MATCGlossyButton.m file?!  Could I be on to something?  Apple being Apple, it should be easy to include the file in the “Compile Sources” with a simple drag and drop.

Let’s fire this up and see what happens now!

Yay!  Success!!

Scroll To Top