4

When I use some custom UI class in Interface Builder from module/frameworks everything work perfect. But if I write extension for this class in my project and set custom class(in Interface Builder), Interface Builder will set module of custom class is my project. And when I try to use this custom class in code, Xcode say:

"Unknown class _TtC9*modulename*18*MyCustomLabel* in Interface Builder file."

An example:

  • TTTAttributedLabel added to new project as separate module(or throw cocoapods).
  • Add simple UILabel in storyboard and set custom class as TTTAttributedLabel
  • Add Outlet to code and print(NSLog) this label.

Xcode write that it is TTTAttributedLabel.

  • add an empty extension to TTTAttributedLabel
 extension TTTAttributedLabel{ }
  • remove and set again custom class for the label in Interface Builder;
  • print(NSLog) the label;

And Xcode write warning message and say that our label is UILabel.

Is it a Interface Builder bug or maybe I must write something before extension for modules?

Info: swift, xcode6.3-7.3

1 Answers1

2

I am seeing the same problem, I seem to have found a workaround though.

In order to avoid this bug, you have to provide the full name of the class including the module name when creating the extension. So it becomes:

extension TTTAttributedLabel. TTTAttributedLabel { }
Steven
  • 419
  • 4
  • 6