2

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

2
  • Do you have your storyboard added to framework target? Commented Jan 29, 2018 at 9:32
  • No,i didn't. i tried it just now,i also tried "tick inherit Module From Target",the same error appeared again.Thank you all the same. Commented Jan 29, 2018 at 10:56

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

You cannot use Storyboards in a static library.

1 Comment

Thanks in advance.Maybe you misunderstand my question.i didn't do that, i use a framework in xib custom class.could you answer it?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.