iosxcodeframeworksstatic-libraries

All framework and static library files compiled to app?


  1. I am wondering whether Xcode compile all the .m sources of frameworks and .a to my app, for example, if I import UIKit framework and I only using UIButton.h, will all files in UIKit be compiled to my app? what about static library?

  2. And if I import some frameworks in building my own static library, will the files of frameworks be compiled into .a?


Solution

  • Linking to standard frameworks like UIKit won't add any extra data to your binary. All of the standard frameworks are part of the OS so you're only making a reference to these frameworks. However, any custom static libraries will have to be included because that compiled code is not a part of the OS.

    The same thing goes for your own library. Importing standard frameworks should not increase the size of your .a file.