merge static libraries into single
lipo
command
Create or operate on a universal file: convert a universal binary to a single architecture file, or vice versa.
lipo
from the liposuction
. As you know when you build a project Xcode generate binary for different CPU architectures.
Unite. When a developer wants to share a producer binary as a closed-sorce he should take into account that a client should have a possibility to run/debug a project with this binary on a real device and a simulator. This simple example shows that the developer has to have a tool to merge binary for different arch into a single file -
fat
binary.Separate. Another example is when you publish an app to AppStore you can remove unnecessary arch using
-remove
option.If you try to build a project with a binary without necessary arch you get an error[Could not find module for architecture]
Architectures:
- Simulator - x86_64, i386
- Device - armv7, armv7s, arm64
If you try run this command for binaries with the same arch you will get
fatal error: <binary_list> have the same architectures (<arch>) and can't be in the same fat output file
Please note that -create
option do not have parameters
lipo libMy_armv6.a libMy_armv7.a libMy_i368.a -create -output libMy.a
To check existing architectures
lipo -info <binary_path>
//or
file <binary_path>
Next step is [XCFramework
]
[Vocabulary]
Open terminal and go to folder with your libs. Then use command:
lipo libSignatureLibary_armv6.a libSignatureLibary_armv7.a libSignatureLibary_i368.a -create -output libSignatureLibary.a