Claudiu Ursache has a nice blog post detailing the command sequence to combine a set of multi-architecture (‘fat’) static libraries into a single static library. I needed to follow this technique for a recent project… and of course preferred to invest more time on the front-side to develop a small tool to automate the process.
This bash script combines all of the .a libraries in a given directory into a single library. It is hardcoded to use the i386, armv7, and armv7s architectures; this can easily be changed at the top, or it may be left as an exercise for the reader to determine the common set of architectures amongst the files. The script takes a single argument, which is the name of the final, combined library to be created.
Another useful script I wrote while working on the same project is a convenient way to combine .a libraries compiled separately into fat binaries. For example, it’s difficult to convince Xcode to build for both i386 (iOS Simulator) and arm (iOS Device) simultaneously. Building each separately, then running this script, produces fat (universal) binaries.