I want to create a static library which contain another static library, how to do?
If you mean embedding dependent library then answer is NO. You can read a little more http://landonf.bikemonkey.org/code/ios/Radar_15800975_iOS_Frameworks.20140112.html or so. I'd recommend to make a Framework instead of static library.
If you just want to make "fat" library which contains different versions of same library for different platforms then answer is YES (Build fat static library (device + simulator) using Xcode and SDK 4+).
Related
I have read many articles about static/dynamic library/framework. So my understanding is (let me know if it's inaccurate):
Framework = Library + Bundle
Static = Linking at build time
Dynamic = Linking at run time
In Xcode, we have "Static Library" and "Framework". Which raises a few confusing points:
Why there's no "Dynamic Library" option?
Given that we can already link framework statically, why do we still need a "Static Library"? (isn't StaticFramework = StaticLibrary + Bundle? )
Why there's no "Dynamic Library" option?
Because Dynamic Library is not permitted for iOS apps at beginning.
Given that we can already link framework statically, why do we still need a "Static Library"? (isn't StaticFramework = StaticLibrary + Bundle? )
Because old Xcode only support Static Library.
Static Framework was added later, and they keep the Static Library.
There are many concepts that must be clear
Libraries have two categories based on how they are linked to the executable file
Static library .a, .so. link at compile time. wiki
Dynamic libraries .dylib .dll etc. link at runtime. only apple can use it for iOS for some safe reason, we cannot build this.
ps, a special kind in apple platform
Text Based .dylib stubs — .tbd
Framework
Framework is a package that can contain resources such as dynamic libraries, strings, headers, images, storyboards etc.
vs Libraries, Framework has more features
Framework also has static and dynamic
iOS 8 later, we can use a dynamic framework, why Apple releases this. maybe Extension and App share code
this Dynamic Framework for iOS is named embedded frameworks, because when we build the app copy the framework in app bundle.
so the embedded framework is different from system dynamic Frameworks like UIKit.Framework
Why there's no "Dynamic Library" option?
the embedded library is allowed with the Framework option, but dynamic framework shared in muti app is also not allowed
Given that we can already link framework statically, why do we still need a "Static Library"? (isn't StaticFramework = StaticLibrary + Bundle? )
well, Xcode not only support Objective-c and Swift, but also support C, C++ which may use the static library
I have a large framework (in my case, opencv2.framework and >300 MB) that my iOS static library depends on. Currently, projects that depend on my static library also need to link the framework. Is it possible to create a single static library that includes the framework in the same .a file? Additionally, can the size of the library be reduced to only contain what it needs so my app is not >300 MB?
If it matters, I'm actually going to use this static library in an iOS binding project, so that it can be consumed by a Xamarin.iOS app.
I am experimenting using Swift static libraries for an iOS app.
This works if the app links to static libraries, as long as there are no cross-dependencies between the libraries.
Where I am having some issues, is when using static libraries from other static libraries. For example, there is a static library with general purpose code, which is used by higher level libraries and the app:
Utilities (shared library)
Database (depends on Utilities)
Network (depends on Utilities)
App (depends on Database, Network, and Utilities)
In an Objective-C or C code base, it would be possible to set the header include path, and link the shared library in the app. Is there an equivalent procedure in Swift?
This is using Swift 4, and Xcode 9.2.
Is this necessary to create static library for creation of framework or we can create it without help of static library what is diffrence betwwen them.
You have two options for creating framework, one is static library (code is linked at compile time) and iOS8 onwards dynamic framework(code is linked at runtime). Refer to following answers for knowing the difference between them :
Library? Static? Dynamic? Or Framework? Project inside another project
I generally don't create static libraries so can you please help me on this;
I have a third party framework and 2 static libraries inside my project so that I will build my own static library by using them. So is it supported to put static libraries and third party frameworks into my project so that I can create my own library? I see that some of the sources say this is not supported while some say it is ok. Please let me know.
Thanks,
E.
technically you would export the third party framework and insert it into your library. When it comes to the static libraries, its possible from that point since your just calling one library from another.