Reputation: 33
i create a project with a framework target and a app target.
in the framework target, i create a class called MyButton inherit the UIButton class.
in the app target, i use the stroryboard and put a UIButton on it,now i use the MyButton class in the interface.
the question is when i set framework target's mach-o type with default option Dynamic library ,i can build and run success. but when i change the mach-o type with Static library option,i can build success but run failed.the error message is "Unknown class MyButton in Interface Builder file."
i am confused with it,anyone can explain it please.
the test demo is here. https://github.com/george-luofz/Test_useFrameworkInXib.git
Upvotes: 2
Views: 472
Reputation: 5543
Elaborating on dasdom's answer, a dynamic framework
is effectively a directory which apart from the compiled binary can contain additional resource files like storyboards, xibs, images etc.
A static framework
is something fundamentally different - it's a piece of compiled code in intermiedate format that must be eventually linked with the final app executable to become usable. It has no placeholder mechanism for additional resource files and is not distributed in a same manner as a dynamic framework
.
A possible (but not very practical) workaround to utilise static framework
would be to serialize a binary resource and embed it in code (becoming effectively an array of bytes - a rather huge one most likely). That would become really hard to maintain and require updating the corresponding deserialised array in code every time the binary resource file has changed.
Upvotes: 1