27

How to merge the static libraries into single one?

I do have three static libraries libSignatureLibary_armv6.a , libSignatureLibary_armv7.a and libSignatureLibary_i368.a

Now i want to merge this three file into one single library which may be named has libSignatureLibary.a

While Googling I found lipo which is open source tool!

Do i need to run any extra scripting language to merge

or in terminal lipo and pass the parameter for the lipo.

Can any on advice me to build the common library for these three.

@thanks in advance Kiran

ThomasW
  • 16,981
  • 4
  • 79
  • 106
kiran
  • 4,285
  • 7
  • 53
  • 98

3 Answers3

50

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
ZGl6YXNt
  • 1,814
  • 18
  • 17
4

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]

yoAlex5
  • 29,217
  • 8
  • 193
  • 205
-1
lipo -create libSignatureLibary_armv6.a libSignatureLibary_armv7.a libSignatureLibary_i368.a -output libSignatureLibary.a
Laurel
  • 5,965
  • 14
  • 31
  • 57
  • lipo -create libSignatureLibary_armv6.a libSignatureLibary_armv7.a libSignatureLibary_i368.a -output libSignatureLibary.a – viveksharma Sep 12 '16 at 08:00
  • Please edit with more information. Code-only and "try this" answers are discouraged, because they contain no searchable content, and don't explain why someone should "try this". – abarisone Sep 12 '16 at 08:53
  • 1
    This is the exact same as the accepted answer with less information. – Jon McClung Sep 11 '18 at 17:42