How does iOS and Xcode link custom frameworks -


i have project includes custom frameworks, these custom frameworks include custom frameworks.

here's sample structure, bullets included frameworks:

app

  • frameworka

  • frameworkb

  • frameworkc

frameworka

  • frameworkc

frameworkb

  • frameworkc

since frameworka , frameworkb link frameworkc, along app using frameworks a, b, , c; linked or framework copied in multiple places?

does increase size of app?

in example frameworkc has assets, if it's copied multiple times wouldn't unnecessarily duplicate data? or there better way?

ios frameworks collection of header files , fat static archive library. ios not support frameworks containing shared libraries.

a fat static archive library collection of multi-architecture object files, object files can extracted needed linker create executable artifact. ios executables self contained executables (except system libraries shared objects).

fat archives can examined lipo.

cd frameworka.framework lipo -info frameworka architectures in fat file: frameworka are: armv7 armv7s i386 arm64  

when create framework, linker tool not used because frameworks (in case frameworka , frameworkb) not executable artifacts. dependent framework included in framework project because compiler requires header files create framework , b object files. references symbols in frameworkc remain unresolved.

if inspect contents of frameworka or frameworkb using "lipo" , "ar" tools , extract object file, dump object file symbols using "nm", notice references symbols in frameworkc remain unresolved.

note: need install xcode commandline tools this.

cd frameworka.framework lipo frameworka -thin armv7 -output frameworka_armv7.a ar -t frameworka_armv7.a objecta1.o objecta2.o objecta3.o  ar -x frameworka_armv7.a objecta1.o xcrun --sdk iphoneos nm -p objecta1.o  ... 00000188 t frameworkafunction          u frameworkcfunction ... 

this why when create app, need 3 frameworks (a,b , c) included in project. when linker reads unresolved symbol in 1 of app object files search framework , b. when symbol resolved, reads in whole object file archive contains symbol. linker must resolve unresolved dependent symbols in object. if 1 of unresolved symbols in frameworkc, pull in object containing dependent symbol frameworkc

so answer questions:

frameworks a,b , c linked when app linked, objects required resolve symbols copied frameworks app executable.

yes, copying in objects increases size of executables, there no multiple copies of of objects.

the assets in frameworkc copied once, when final app bundle assembled xcode.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

Kivy: Swiping (Carousel & ScreenManager) -

jdbc - Not able to establish database connection in eclipse -