Multiple static libraries with a shared dependency - iOS

ios, linker, static-libraries, xcode

Solution

For anyone else wondering about this, I've found that you can get the behavior I wanted by including header files with each library, but only linking with one.

In the example I outlined in my question, my primary project would link against A, B and C. However, to use A in libraries B & C, you can include the header files of A in B & C, but then only link against A in the root project.

If anyone has a better suggestion, please feel free to share.

As an aside, there's a project called Cocoapods that is an iOS dependency manager. It seems to be worth keeping an eye on.

Problem

I am working on several iOS projects which will have a good bit of shared code, so I'm collecting that code in static libraries. Now let's say I have 3 static libraries I'm working with: - Lib A contains generic utility functions - Lib B contains one set of classes - Lib C contains a second set of classes (and A is a dependency of both B and C) Now, my final project needs to utilize functionality from all three libraries. I know that A could be staticly linked with B, C, and my final project, but at that point I would get a linker error because there are multiple implementations of the same classes. How should a situation like this be handled?

Original source