1. A project depends on another project
1. First we create two projects DemoA and DemoB (open Xcode, Command + Shift + N, two ios apps)
2. CD DemoA, create a Framework folder, and drag DemoB into the Framework folder, as shown in the following figure
You can use 3.1 to drag the Framework folder in DemoA into the Xcode project. This will cause an error during the compilation process. The solution is to remove the demob-related files in the figure below. You only need to keep DemoA’s.
3.2 You can do this in Xcode as shown below, so that the problems in 3.1 will not occur
4. Suppose you have a Person class in DemoB, and you need to use the Person class in DemoA. You can associate the Person class with the framework by creating a framework in DemoB. From the Framework you can use the Person class in DemoA by following the steps below
4.1 If you do not check the Target of DemoBFramework, you will not see the.h file of person in 4.3
4.2 correlation target
4.3 Put the person. H file in public
Add a link binary with Libraries to your DemoA dependencies dependencies file. Add a link binary with Libraries to your DemoA dependencies file
4.5 Import the Person class in the framework header file as shown below, otherwise there will be a warning, you can try it yourself
5. You are now ready to use the Person class in DemoA
2. The project depends on the framework
I don’t need to say this, but it’s the same operation as above
3. The project relies on Static Library
The process of relying on Static Library is similar to that of the Framework, but the details of the process are a bit more complicated. In fact, once you know the process of relying on Static Library, you should know the process of making.a. Our next requirement is to rely on a Static Library in DemoA.
1. We add a Static Library directly to the above project
2. Next we create a Human class and write an instance method of walk.
3. Import human.h in Static Library
4. If you need a public header file, you can add it to the header file. Here we have public StaticLibrary.
Add Link Binary With Libraries to add Dependencies to the Static Library when you add DemoA to your database.
6. So you can call it
We’ve gone through the process very briefly, but what if you want to pack a.A bag? Let’s start with xcode12.
Debug build Active Architecture Only to NO in build Setting. This value should have been YES. When you select an emulator in Debug mode and press Command + B to compile it, you will not only compile the architecture for that model, but also compile all supported architectures just like release.
8. Select the current Static Library scheme and use the iPhone 12 Pro Max simulator to compile.
9. At this time, you can find the folder where. A is located as shown in the following figure
10. CD to this file, execute lipo-info StaticLibrary. A you can find the StaticLibrary we have packaged for arm64 x86_64 i386 architecture.
A library does not support arm64 architecture? In the Excluded Architecture, suppose we set the Any ios Simulator SDK to arm64 under debug and release as shown below. So when we compile in the emulator, whether it’s debug or release, we compile.A files that don’t support arm64, only when we compile in the emulator.
12. In the real environment, scheme select Any iOS Device. There is another point to note here, if you compile.a library that only supports ARM64 without changing the lowest supported version, follow the following steps to change the lowest supported version, then you can support ARMV7.
13. Now that we have compiled the emulator and real versions of the.a file, use the show in Finder above to find the path to the.a folder. The next step should be the final step, merging.a files, which will only support the emulator version of.A and only support the real environment, so that the merged.A will support the real machine as well as the emulator.
LibStaticLibrary. A supports only x86_64 and i386, you can check by checking lipo-info libStaticLibrary.
15. Then let’s look at the real environment, I support arm64, ARMV7.
16. Lipo-create (StaticLibrary path here)/ emulator version. A (StaticLibrary path here)/ real version. A-output (path here you want to output)/ output name
17. Remember to save the include folder (you can assign the emulator or real environment directly, as you can see in Step 13), and you’re done
That’s it. If you run into sporadic problems during production, do a search for them yourself.