I have a big static library I would like to package into an iOS static framework for ease of use. The library is actually several .a
files, one per logical module of the library.
I have the compiled .a
files built for the device (fat file with armv7
, armv7s
, arm64
) and for the simulator (fat file with i386
, x86_64
).
Now, AFAIK, I need to combine all those files into one big file in order to build a proper framework.
Using the technique described here (Combine static libraries), I could do :
libtool -static -o new.a old1.a old2.a
But apparently both old1.a
and old2.a
include the same symbols. Thus, when linking against my framework, I get the linker error (for a valid reason) duplicate symbols
.
A more correct way to do that (thus avoiding duplicate symbols) seems to be unpacking the .o
files, and combining them into a big .a
file (How to pack multiple library archives (.a) into one archive file?)
ar x old1.a
ar x old2.a
ar rcs new.a *.o
Now, remember, old1.a
and old2.a
are fat files, so I need to separate that per architecture.
So here's what I do:
lipo old1.a -thin armv7 -output armv7/old1.a
cd armv7; ar x old1.a; cd ..
...
lipo old1.a -thin x86_64 -output x86_64/old1.a
cd x86_64; ar x old1.a; cd ..
// Same goes for old2.a ...
// Then,
libtool -static -o new.a armv7/*.o armv7s/*.o arm64/*.o // ... etc
But for some reason ,when linking against the thus created framework, the linker can't find any symbol (even though nm
reveals them all).
Any idea how to build that static framework?