What is a library? Libraries are ways of sharing program code. They are generally divided into static libraries and dynamic libraries.

Static library: complete copy to executable file when linking, multiple use of multiple redundant copies.

Dynamic library: link does not copy, program run by the system dynamically loaded into memory, for program call, the system only loaded once, multiple programs shared, saving memory.

The advantages of static and dynamic libraries

Benefits of using static libraries:

1, modular, division of work cooperation 2, avoid a small number of changes often lead to a large number of repeated compilation links 3, can also be reused, note that not shared use of dynamic library use has the following benefits: 2. Using dynamic library, multiple applications share the same library file in memory, saving resources. 3. Using dynamic library, you can update the dynamic library file to update the application program without recompiling and connecting the executable program. It can be concluded from 1 that the whole application is divided into modules, teamwork and division of labor, with relatively little influence. From 2, we can see that dynamic libraries should be called shared libraries. In this sense, it is understandable that Apple prohibits the use of dynamic libraries in iOS development. Because on today’s iPhone, iPodTouch, and iPad applications are single-process, meaning only one process is running at a time, you write a shared library, —-, and share it with whom? Only one application exists when you use it, the others should be suspended, even if multiple processes are running at the same time, can others use your shared library? Yours is customized for your own program. —- Currently, Apple’s AppStore does not support module updates, so you cannot update a single file (unless you write your own update mechanism: you have your own server to place the latest dynamic library files).

I can only guess why Apple has banned dynamic libraries for ios development

Static library and dynamic library form in iOS? Static libraries:.a and. Framework Dynamic libraries:.dylib and. Framework

Why is framework both a static library and a dynamic library? The. Framework of the 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. The. Framework has resource files in addition to binary files. A files cannot be used directly, but at least a. H file must be used together. Framework files can be used directly. .a +.h + sourceFile =.framework. Proposed framework.

Why use a static library?

Easy to share code, easy to use. Achieve iOS program modularization. You can modularize a fixed business into a static library. Share your code base but don’t want anyone to see the implementation of your code. The need to develop third party SDKS.

Seven, the production of static library points to note: 1 Attention understanding: Whether the. A static library or. Framework static library, we need to be binary files +. H + other resource files, the difference is that. A is a binary file, we need to match.

2. Image resource processing: Two static libraries, usually put image files in a separate. Bundle file. The.bundle file is easy to do, just create a new folder, rename it.bundle, right click, display the contents of the package and add images to it.

3 categories are often used in real development projects. There is no problem with classifying a category into a static library, but in projects using this static library, there is a runtime error when calling a method in a category (selector not recognized). The workaround is to set other Linker Flags to -objc in projects that use static libraries.

4 if a static library is very complex, needs to be exposed. H is more, can be in internal creates a static library. H file (generally the. H file name and the name of the static library), and then put all need to be exposed. H file is focused on this. H file, and those that need to be exposed. H don’t need to be exposed, You just have to expose the dot h.