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

What is the difference between static 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.

Static library form in iOS? .a and.framework 4, iOS dynamic library form? .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 static libraries? 1 easy to share code, easy to use. 2 Achieve the modularization of iOS programs. You can modularize a fixed business into a static library. Share your code base, but don’t want anyone to see the implementation. 4 Need to develop third-party SDKS.

Eight, 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.

The above is excerpted from the differences between.A and.framework libraries in iOS

Make your own framework

1. Create a project file

Target -> Build Settings; Set Dead Code Stripping and Link With Standard Libraries to NO and Mach-O Type to StaticLibrary.

armv7s

4. Exposed header files (1) Public header files ——-Public (2) hidden header files ——-Private or Project are no longer referenced.

5. Import all exposed header files into the framework’s.h files

6. Select the emulator and the real machine respectively and run the compilation. The command + B; Go to Framework -> Show in Finder and two frameworks will be generated, one for the real machine and one for the simulator.

7. Merging two frameworks can be done using terminals or scripts. Script I don’t know ah, I use terminal. O ha ha ~ O (studying studying)

Use the command lipo-create from the terminal

  1. Lipo-create Command to merge files
  2. Generate framework path under real machine compilation
  3. Generate framework path under test machine compilation
  4. -output Indicates the input command
  5. The path where the composite file will be stored
  6. Error This error is negligible

8. Replace the file Drag the generated file to the framework generated in Step 6 and replace the name with your framework name. Change the suffix directly, in this case, the TestFramework.

9. Framework is completed

10. Drag the framework completed in step 9 to the project you need to use. Introduce header files and call methods directly.

At this point, making your own static framework references is complete.

PS: This production method is too low, awesome can seeCarthage generated framework; Follow-up research.