I am developing a graphic library in Swift. The code cannot be shared, but I made a sample here (see the button example, Radio buttons were dedicated to another question).
I would like to have a namespace MyGraphicLibrary
for my components: MyGraphicLibrary.Button
instead of MyGraphicLibraryButton
The sample pod has two classes:
// Independent class
@IBDesignable public class CustomButton: UIButton {
...
}
// Namespace for my components
public class MyGraphicLibrary: NSObject {
}
// Namespaced button
public extension MyGraphicLibrary {
@objc(MyGraphicLibraryButton) @IBDesignable class Button: UIButton {
...
}
}
The CustomButton
class is behaving as expected in the interface builder: I can easily add the custom class to the button (see Main.storyboard
).
For the nested class, it is not possible to set it with its normal name (Button
or MyGraphicLibrary.Button
).
The only way is to set the class @objc name MyGraphicLibraryButton
; there is no autocompletion and the module must be set to none
(which looks like a nonsense, the class belongs to the GraphicLibrary module). Removing the @objc name makes no difference.
Is there a way to make the nested class be handled correctly by the Interface Builder?