Static libraries and dynamic libraries
First, add the knowledge of the static and dynamic libraries. I am not familiar with this part of the content, no development experience, such as the wrong welcome to face.
Static Library
The code of the Static library is appended to the executable file, and multiple copies of it are used to make redundant copy.
The advantage is that the application package itself can run independently, but the downside is that the package is slightly bloated and the library cannot be shared.
The static library in IOS is in the form of. A and. Framework (the. Framework that you create is a static library).
. A
. A files need to provide header files and resource files when they are actually used. This is the way it was provided by default in Xcode. However, compiling a static library only supports a specific hardware architecture, and if you want to generate a Universal static library, you need to combine multiple static libraries with a tool. And the use of the time need to cooperate with the. h file, in contrast to the framework will be a better choice.
. framework
The framework can contain not only binary files, but also header files, resource files, and even multiple versions. However, each application uses its own common library, which ultimately requires the link into the executable file, so it is essentially a static library.
Dynamic Library
Dynamic library code and executable files are separate, the program run by the system dynamically loaded into memory, the system is loaded only once, multiple programs shared memory savings.
The advantages and disadvantages of dynamic libraries in contrast to static libraries, dynamic-link libraries require a library environment, but because they do not integrate library content, they are small and also provide the possibility to use shared libraries with other applications.
The dynamic library in IOS is in the form of. Dylib and. Framework (the system's. Framework is a dynamic library).
Present situation
For security reasons, AppStore does not allow the use of third-party dynamic-link libraries. We can write our own public libraries through the framework. As Xcode6 begins to support the new framework, it is no longer necessary to manually configure it. Ios-universal-framework also announced the discontinuation of the update.
Module
The modularity (modules) was presented in the 2012 LLVM developers meeting. Simply put, the tree-shaped structure of the description to replace the previous flat #include
, to encapsulate the framework, so as to solve the previous methods of vulnerability and lack of extensibility problems. (This paragraph I do not quite understand, just translated a bit ...) )
Take UIKit as an example, module.map
presumably like this:
framework module UIKit { umbrella header "UIKit.h" module * {export *} link framework "UIKit"}
Use it when you are using it @import
. It must be a huge project if all the code needs to be rewritten, so Apple has done this part of the work ahead of time. As long as the use of IOS7 SDK, will Enable Modules open, and then keep the original way of writing #import
, the compiler will be in the compilation of the time automatically to replace the possible place to Modules to compile.
References
- Module System of Swift
- How iOS creates and uses static libraries
- dynamic-link libraries and static-link libraries in iOS development
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Common library and modularity of Swift learning notes