Introduction In enterprise development, some core technologies or commonly used frameworks do not want to be known to the outside world for security and stability reasons, so the core code is packaged into a static library and only the header file is exposed to programmers (for example: third-party SDKs such as Umeng and Baidu Maps) The existence of static libraries and dynamic libraries
The difference between static libraries and dynamic libraries
Note: If dynamic libraries are used in the project, Apple will reject it. Static library file versions (4 types)
Debug version
Release
Therefore, we usually package the Release version in development to provide the outside world Introduction to the device's CPU architecture (supplemental knowledge) Simulator:
Real machine:
Making a static library - Debug version 1. Create a new project 2. Add a static library and name it 3. The code that needs to be packaged into the static library is placed in this folder 4. Recreate the test class (HSCalculate) to provide a method for external users to calculate the sum of two numbers HSCalculate.h
HSCalculate.m
5. Files (interfaces) that need to be exposed to the outside world #p# 6. Package static libraries that support simulators and real machines (select real machines and simulators to run respectively, and the corresponding static libraries will be generated) 7. View the packaged static library Two folders, the .a file inside is the packaged static library
You can use the following command to view the CPU architecture supported by the static library (you can view the CPU architecture type described above)
Check the CPU architectures supported by the static libraries of the packaged simulator and real machine respectively You will find that the simulator's static library is missing 4s~5: i386 architecture reason: Debug: Yes means compiling only the architecture corresponding to the selected simulator, while No means compiling all the CPU architectures supported by the simulator (change the Yes status of Debug to No) After modification, recompile: 8. In this project, debug the static library, import HSCalculate.h into ViewController.m, and run the test. You will find an error.
Error: reason: Need to import static library (compile to run successfully) 9. Support static libraries for both real devices and simulators (need to be merged) The static libraries of the real machine and the simulator are different and cannot be applied to both the real machine and the simulator at the same time. However, to meet this requirement, the two compiled static libraries must be merged. Merge good or bad:
Merge to generate a new static library:
10. Pull the merged static library and externally accessed files into the new project and you can use it (created by the inc file itself) New construction test: Making a static library - Release version The steps are the same as the Debug version, except that when compiling, change the following options Making a static library - .framework version The steps are basically the same as making a .a static library, but pay attention to the following points: 1. Select framework 2. When compiling, it is made into a dynamic library by default. You need to select 3. When merging static libraries, select the libstaticlib file in the .framework file merge: Delete libstaticlib, pull libCalculateTool into the libstaticlib.framework project, and the libstaticlib.framework static library is created |
<<: Essential for APP to go global: How to win the European and American markets
>>: Apple releases first iOS 9.1 beta to public beta users
July 5 afternoon Tuanbei Village, Tuanzhou Townsh...
In the autumn in Alaska's Glacier Bay Park, p...
I want to tell everyone: Don’t just focus on Baid...
Earlier, the world-renowned medical journal "...
Some time ago, Migu Reading launched the "Ch...
"I think the next 20 years will probably be ...
Nowadays, “two Weibo and one Douyin” have become ...
If selling cars is not profitable, what will the ...
Hammer Technology's history of having no flag...
On January 3, Tuhu Auto Care issued a statement r...
During the "618" e-commerce festival, a...
In recent years, "I am autistic" has be...
As the saying goes, the Chinese New Year is over ...
1. Event Planning Overview There are three keys t...
Campus safety is of great importance These safety...