I have a big iOS project that consists from several (about 20-30) static libraries that link together into final executable. Some of the components are platform-independent (pure C++) and some are iOS-specific (Obj-C/Obj-C++). C++ templates are used intensively, so each object file contains lots of symbols with vague linkage. The problem is that these symbols are merged only during linking of the final executable, but not when making static libraries. Each library contains tons of duplicated symbols (6-60 clones). So final linking of the app takes several minutes. This becomes extremely annoying when debugging and doing some small changes.
Is there a way to perform merging of the symbols with vague linkage for each library?
I known, that this is done automatically when using dynamic libraries. With some hacking (http://sumgroup.wikispaces.com/iPhone_Dynamic_Library) it is possible to build dynamic libraries for iOS. Is there a way to link dylib's statically (link them into a single executable file)?
Of course, being able to debug resulting app is a must.
If you’re using your own library, or if you have access to the source and project files, adding the library as a subproject provides a convenient way to import a static library in your app. You get closer build integration as a project dependency, with fewer things to worry about doing yourself.
You will notice the usual Xcode “Run” button just performs a build; you can’t actually run your library to see the results as there’s no app behind it! Rather than a .app or a .ipa file, a static library has the .a extension. You can find the generated static library in the Products folder in the project navigator.
Rather than a .app or a .ipa file, a static library has the .a extension. You can find the generated static library in the Products folder in the project navigator.
All iOS and macOS system libraries are dynamic. Hence our apps will benefit from the future improvements that Apple makes to standard library frameworks without creating and shipping new builds. When we link system libraries, such as UIKit or Foundation, we don’t want to copy their entirety into the app, because it would be too large.
You can pre-link your static library objects into a single one, also you can prelink other static libraries into one. It will actually link objects with the linker (almost like in dynamic library).
Perform Single-Object Prelink
in Linking sections. Switch that to Yes$(CONFIGURATION_BUILD_DIR)
variable. So if you have library foo, then it will be $(CONFIGURATION_BUILD_DIR)/libfoo.a
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With