How can the error "Unknown class <MyClass> in the Interface Builder file" be fixed if the line reads "[Class MyClass]"?
I read the following answer, so I know that the "Unknown class in the interface constructor file" can be resolved using the -ObjC linker option. (FYI, MyClass is in the static library.)
stack overflow
I also found that one line of code [MyClass class] in the application’s delta can handle the same problem without using the -ObjC option. My question is how the code works.
According to the answer I added above, an error occurs because the characters in my static libraries are not loading. Then does this mean that the [MyClass class] forces Linker to load a character at runtime? (which does not make sense)
The component will attempt to reduce the final binary size by deleting unused characters. Classes created from Storyboard are created using reflection, and therefore the linker cannot know whether this class is used, therefore it is removed from the final binary file.
By adding this line to your code, you force the linker to add this class at compile time (and not at run time), making the reflection call from the Storyboard work as expected.
I also ran into this problem. The accepted answer did not allow my answer. This is what my answer resolved, and I think it really is the way it should be done:
In IB, where you can select your class, there is another drop-down menu at the bottom right, where you enter the name of your class called "Module". Here you can choose nothing (for classes in Objective-C), or you can choose a pre-populated module, usually the name of your application. If you do this, the runtime understands that this class works in the named Swift module and can load it.
This works for a project that only started with Obj-C, and added some quick classes later.