In the implementation of the iOS modular development process, the fixed business module can be the static library.
This article will create a simple project based on Xcode9.2 that teaches you how to create your own framework, with the goal of making the framework simple and easy to learn. This approach makes it easy to share your code, reuse it in multiple projects, and hide implementation details to control the exposed header files.
1. Open Xcode and create a new project. Do not select "Application" and select "Framework & Library". Select First, then next.
2. Create a related function class
I have created a SayHello class here.
3. Implementing Functional Classes
I wrote a SayHello method in the SayHello class and implemented the method
4. Changing parameters
Under Targets, select the project and change several parameters under Build settings.
5. Increase armv7s
Under architectures, add armv7s and select. Set build Active Architecture only to No.
6. Set headers
Drag the header file you want to expose to public, hide it under private or project, and, of course, the hidden header file can no longer be referenced.
You then need to introduce all of the. h that you want to expose in TestFramework.h (must be public, otherwise it cannot be referenced).
7. Start packaging the Framework
1> Check Simulator, compile program
2> Check the test machine, compile the program
3> finding the framework file in the Finder
Select the framework shown in the diagram and right-click the show in Finder.
Find the test file shown in, one is Debug-iphoneos (real machine), one is under the Debug-iphonesimulator (simulator).
The 4> uses a terminal command to combine two frameworks into an emulator and a framework that can be used by a real machine.
Open the console input lipo-create Iphoneos under Testframework path simulator testframework The path-output the new path, thus completing the merger of the emulator and the real machine version, The testframework under the new path is your merged file, change the name of the file to the same name as the test that you did not merge, put it under the Framework folder, and replace the original Testframework file.
5> the modified framework copy and save it, and this is the framework we made.
The iOS encapsulation feature generates a static library. Framework