objective c - iOS Static Library | Linking only USED symbols -
i using third party ios static libraries , having trouble keeping binary size small. libraries using have objective-c interface backed native c/c++ code. issue of symbols library (checked nm) being included in app when linked (even if don't reference of code in library). contrary understanding of static libraries code application (or other linked libraries) reference pulled application.
i've done bunch of reading , have found due dynamic nature of objective-c, there particular issues can arise linking object files or static libraries containing objective-c category methods. because of this, can pass -objc flag linker have linker pull in object files containing objective-c classes or categories. ensures classes , categories defined @ runtime, bloats app's binary unused objective-c classes/categories/method definitions.
strangely enough, seeing effects of adding -objc linker flag while not using anywhere in build. of objective-c symbols being included, , consequence, of native c/c++ symbols objective-c code references, whether or not app references of code in library. has else experienced problem or found solution it?
os x 10.11.4 , xcode 7.3.
first, disclaimer: haven't tried solution describe here (all projects i've worked on use -objc
flag indiscriminately), ymmv.
that said, might of use: https://github.com/cocoapods/cocoapods/issues/712
basically, idea is, rather using -objc
carpet bomb, can more targeted load on per-library basis: -force_load $(target_build_dir)/lib<yourlibname>.a
.
the author of referenced link mentions cocoapods culprit specific problem encountered, think (hope) solution apply more general question you're asking.
as question of why have bother, thing can find comes close actual explanation can found here: https://developer.apple.com/library/mac/qa/qa1490/_index.html. post describes "impedance mismatch" between unix (bsd) static libraries , more dynamic objective-c based libraries (even static ones) containing e.g. categories. current linkers can't make required connections @ compile/link time methods bound @ runtime, these linker flags workaround problem.
Comments
Post a Comment