3

Just to clarify, I am not talking about merging different architectures static libraries into one here.

I have a static library that depends on several other static libraries. The problem is that I don't want our customer to bother to include all those .a files, but instead only one containing all the objects and code they need.

So how could I merge several static libraries into one? Or is it possible to include those static libraries when I build the static library through XCode?

Patroclus
  • 1,163
  • 13
  • 31
  • You can use `libtool`. See https://stackoverflow.com/questions/9531014/linking-2-static-libs-into-1-for-ios/21225126#21225126 for a more detailed answer. – spnkr Apr 22 '21 at 03:57

1 Answers1

6

You can use libtool command line utility for this. Here is the syntax:

Let’s say the directory libs has all the static libs and you want to create libfatstatic.a out of it.

libtool -static -o libfatstatic.a libs/*.a

Note: If you don’t have libtool. You can install the same using brew : brew install libtool

manishg
  • 9,520
  • 1
  • 16
  • 19
  • When merging those files, I received a bunch of warning saying that for xxx architecture, there is no symbol in xxx.a. And after import the merged static library, I didn't have errors in compile-time but have run-time error.. What may be the reason of this? – Patroclus Aug 10 '18 at 18:05
  • So you do not get any errors if you include those files without merging? – manishg Aug 10 '18 at 18:20