Xcode - Add Static Library to Another Static Library

I need to create an iOS static library (A) that includes another library (B), but I don't have the source code for library B. I only have the .a file and headers. Is it possible?

I created a project with 2 targets, 1 is the target test, 2 is the target for the library. How do I correctly add library B to target 2? I only need one library.

+3


source to share


2 answers


Static libraries do not link and are simply a collection of object files, however you can package object files from both libraries into one file .a

.

You can write Post Build Script in your target Xcode static library that combines both libraries by unpacking them and then recreating the new library, however getting the correct paths (i.e. using the correct Xcode environment variables) can be tricky.



This is something like:

ar x libyours.a
ar x libtheirs.a
rm -f libyours.a
ar c libyours.a *.o

      

+1


source


Add old library B to Porject A as usual. Then, in your target static library, add library B under Link to Binaries with Libraries.



0


source







All Articles