Tools & releasesHistorical technical note

Packaging an iOS static library as an .a file

Records a workflow for building separate device and simulator static libraries in Xcode, inspecting their architectures with lipo and combining the .a files. It explains matching the target platform during testing and checking the resulting library.

Author:

Originally credited to Bison. Content is retained as published.

English translation of the Chinese original, translated on . The article body uses automated translation; app descriptions, historical reading notes and video subtitles receive separate editorial checks. Original publication dates, attribution, code and version notes are retained.

"iOS development: generating a static .a library." Plato

0

1

2

3

4

5

10

11

Select iOS Device. I recommend leaving the device disconnected here, then running command+b.

Then select a simulator and run command+b.

This produces two .a files.

6

7

8

9

10

If you are not testing on a physical device, use the simulator .a file. Otherwise an error occurs.

Next, combine the device and simulator .a files.

cd + .a 路径

Use lipo -info .a文件名 to inspect the file information. lipo -create xxx/.a文件 xxx/.a文件 -output xxx.a文件

The xxx/.a files refer to the paths of the device and simulator .a files.

The xxx.a file is the generated .a file.

The new file is twice the size of the original. Then test whether it worked.