16

I am trying to subclass my UIButton on my Storyboard with a custom swift class that should show the button as a custom Hamburger Button.

I am getting this warning and not seeing the Hamburger button being rendered in Interface Builder, although it will intermittently work.

The Custom class is called NTHamburgerButton, I don't know why the string on characters is appearing before the class name.

IB Designables: Using class UIButton for object with custom class because the class _TtC6CProjectName17NTHamburgerButton does not exist.

Codermonk
  • 883
  • 16
  • 32
  • Similar problems reported here: http://stackoverflow.com/questions/26674111/ib-designable-ibinspectable-interface-builder-does-not-update. – Martin R Jun 22 '15 at 19:49
  • It seems like it is working now since I added some IBInspectable attributes to the custom class, I did not need them to be Inspectable, but at least it makes the Interface Builder work as expected – Codermonk Jun 22 '15 at 20:40

5 Answers5

9

I've encounter the same problem, and I found an answer from other question: enter link description here

I just Refresh All Views enter image description here

It works to me. Hope it helps you too.

Community
  • 1
  • 1
funclosure
  • 498
  • 6
  • 15
6

This question seems to be getting some attention again so I'll give an update.

This issue existed in a Obj-C and Swift mixed project. So the Class in question was a Swift Class.

When making Swift classes available in Obj-C, you can use the following syntax

@objc(NTHamburgerButton) public class NTHamburgerButton : UIButton {}

Otherwise in your {Project-Name}-Swift.h file that Xcode Creates you will see that it generates these unique class names like that from the question.

The only real issue here was that the NTHamburgerButton.swift file was not being included in the Product I was looking at the at time, but if I switched targets, it worked fine. Thus the intermittent issue.

Codermonk
  • 883
  • 16
  • 32
5

For me both solutions of Codermonk and specialvict was necessary, but not enough.

I also had to turn on Inherit From Target in Interface Builder:

enter image description here

This did the trick for me.

Daniele Ceglia
  • 849
  • 8
  • 12
  • I've imported a IBDesignable class in cocapods, and it was just an ObjC class with swift header inside causing same warning, and to make it work I had to choose the imported class in "Module" combo to make it work – Robert Juz Jun 14 '17 at 06:27
0

I struggled with this error in Xcode 11 even after applying the other solutions given.

In my case, I had my own @IBDesignable class residing in the main module (so, not from a CocoaPod or other external module). Yet even when specifying an objc(ClassName) for my view class, the auto generated class name was still being used by Interface Builder at build time.

Finally, I removed the module name and module inheritance in IB and that removed the error and got the view preview rendering:

So, the complete solution for me was:

  1. Declare an Objective-C class name for the Swift class
  2. Configure the class in Interface Builder as shown above

Both are seemingly required in Swift as of Xcode 11. Notably, I had no issues with the view at runtime despite removing the module reference. I am also unsure how this solution would look for views imported from other modules.

Nathan Hosselton
  • 1,089
  • 1
  • 12
  • 16
0

This started happening to me in Xcode 12.1. Thus far, simply un-checking then re-checking the "Inherit Module From Target" in Interface Builder seems to have solved the problem.

Paul
  • 115
  • 2
  • 10