First, what is a library?
Library is the way to share program code, generally divided into static library and dynamic library.
Second, the static library and the dynamic library of the difference?
A library is essentially a binary format of executable code that can be loaded into memory for execution. There are two kinds of library, static library and dynamic library.
Static libraries: When the program compiles, it is completely linked to the target code, and the program will no longer need to change the static library when it is run. The use of the static function library compiled into a larger file, because the entire library of all the data will be integrated into the target code, his advantage is obvious, that the compiled execution program does not require external library support, because all the functions used have been compiled. This, of course, will also be a disadvantage, because if the static library changes, then your program must be recompiled.
Dynamic Library: At the time of the program compile and not be linked to the target code, the program runtime is dynamically loaded into memory by the system for program calls, the system is loaded only once, multiple programs are shared, saving memory. Compared to the static function library, the dynamic function library is compiled without being compiled into the target code, and your program executes to the relevant function to invoke the corresponding function in the library, so the dynamic function library produces less executable files. Since the library is not integrated into your program, it is applied and invoked dynamically while the program is running, so you must provide the appropriate library in the running environment of the program. The change of dynamic function library does not affect your program, so the upgrade of dynamic function library is more convenient.
Apple prohibits the use of dynamic libraries in iOS development.
Third, the form of static library in iOS?
. A and. Framework
Iv. Dynamic Library form in iOS?
. Dylib and. Framework
V. Why is the framework a static and dynamic library?
The. Framework of a system is a dynamic library, which we build ourselves. The framework is a static library.
What is the difference between a and. Framework?
. A is a pure binary file, and the. Framework has a resource file in addition to the binaries.
. A files cannot be used directly, at least with. h files, and. Framework files can be used directly.
. A +. H + sourcefile =. Framework.
Suggested use the. Framework.
Vii. Why use a static library?
Easy to share code for reasonable use.
Implement the modularity of iOS programs. A fixed business module can be made into a static library.
Share your code base with others, but don't want others to see your code implemented.
The need to develop a third-party SDK.
Eight, the production of static Library of several notes:
1 Note: either the. A static library or the. Framework static library, all we need is a binary file +.h+ other resource files, different,. A is itself a binary file, We need our own. h and other files to use, and. The framework itself already contains. h and other files that can be used directly.
2 Image Resources processing: two static libraries, usually the picture file is placed in a separate. bundle file, general. The name of the bundle is the same as the name of the. A or. Framework. bundle files are good, create a new folder, Rename it to. Bundle on it, right-click to display the contents of the package to which you can add a picture resource.
3category is often used in our actual development projects, it is no problem to make the category into a static library, but in the project using this static library, there will be no runtime error finding the method when calling the method in the category (selector not recognized), the workaround is to configure other linker flags with a value of-OBJC in a project that uses a static library.
4 If a static library is complex, If you need to expose the. h more, you can create an. h file inside the static library (typically the name of the. h file is the same as the name of the static library), and then put all of the. h files that need to be exposed in this. h file, and those that need to be exposed. h do not need to be exposed, just have to expose the. h.