Reputation: 35
I need to make a iOS static library (A) that include another library (B), but I don't have source code for library B. I only have a .a file and headers. Is it possible?
I created project with 2 targets, 1 - test target, 2 - target for library. How to add library B to target 2 correctly? I need only one library in result.
Upvotes: 3
Views: 486
Reputation: 9731
Static libraries don't link and are simply a collection of object files, however you can package the object files from both libraries into a single .a
file.
You could write an Post Build Script on your static library Xcode target that combines both libraries by unpacking them and then recreating the new library, however getting the right paths (i.e. using the correct Xcode environment variables) could be tricky.
It's something like:
ar x libyours.a
ar x libtheirs.a
rm -f libyours.a
ar c libyours.a *.o
Upvotes: 2
Reputation: 5181
Add static library B into Porject A as usual. Then in your static library target add library B in to 'Link Binary with Libraries' should work.
Upvotes: 0