New projects to take over to restructure, planning to component direction. The idea of componentization probably involves the encapsulation of static libraries, which I studied before but didn’t blog at the time, so I didn’t document it. It is not very convenient to use it by yourself, now plan to summarize from the package static library here!

Static library production

Here I recommend you to read this article, I feel that the author wrote very well, relatively detailed and comprehensive. Static library production here itself is just a summary of the simplification and mining of the operation process. (Here I use the official recommended. Framework static library)

    1. Create a new SDK project.

    1. This file is created by default and acts as the unified management header file in the project.

    1. YTKTestManagerIs a newly created class, and then the header file inYTKTestSDK.hIt’s referenced in this file.

    1. Find it in XcodeBuild PhaseTo perform the following configuration, you need to expose the files in thePublicBelow, put what you want to hide intoPrivateDown hereYTKTestManager.hThe header file needs to be dragged directly from the projectPublicBottom, or click on the bottom+Without it.

    1. Proceed with the following configuration

    1. Proceed with the following configuration

Arm64 CPU architecture See CPU architecture description here

    1. Proceed with the following configuration

    1. Real machine compilation generates SDK

    1. The simulator

Build the SDK

  • 10. View the compiled framework

  • 11. Merge the framework files compiled by the real machine and simulatorlipo -create Command merge:

Path Description Lipo-create + YTKTestSDK in the framework compiled by the simulator + YTKTestSDK in the framework compiled by the real machine + -output + The path to save after the merge

Note: The static library compiled by the simulator and the static library compiled by the real machine failed to merge. Have the same architectures (ARM64) and can’t be in the same fat output file

  • 12. The following files were dumped after the merger:

  • 13. Remove suffixeslipoThen drag the compiled file into the following folder to replace the file.

  • 14. Finally, copy the whole picture below to the desktop, so that a framework static library suitable for real machine and emulator is completed.