So I have nested Static Libraries several times in the past but never quite like this and its causing a bit of an issue.
For now lets assume I have 3 static libraries, A, B, and C. And one project that uses them as follows.
A is a base library composed of commonly used Custom Views, Data structures, and Categories. B is a library linked with A that contains view controllers shared among several projects. C is another library linked with A that contains view controllers shared among several projects.
This particular project uses code from B and C. So the structure looks like this:
A
/ \
B C
\ /
Project
And since the way Xcode links static libraries basically merges them, B and C both have all of A's symbols. So I'm getting the duplicate symbols linker error. How do I go about dealing with this? Do I need to weak link something? Or is there a particular flag I'm missing? Do I need to set up some type of dependency other thank linking binaries?
I've googled and search here and found lots of good information but nothing I've been able to twist into this particular situation.
Update on Thoughts
So let me ask this as it seems to be a possible solution after reading that Static Libraries while capable of being merged really shouldn't be.
Rather than having 3 independent Static Libraries should I put them all in one project and merely have multiple static library targets? Not even using Target Dependencies, just A, AB, and AC, and ABC targets that include the proper files and headers for their target? This will no doubt be rather complicated for build settings and could make source distribution a bit complex, but it would solve my current problem and possible be the better way to handle things. Whatcha think?
BandCcontainA's symbols? That doesn't sound right at all. - trojanfoeBis a static library andAis static library, thenProjectmust link with bothAandB. In other wordsBdoes not containAuntil the final link with the binary. - trojanfoe.afile) is simply an archive of.ofiles. You need to breakAfromBandCso make them separate Xcode projects and use a Workspace to bring them together.BandCwill have to seeA's header files but it won't link any ofA's objects files.Projectwill need to see{A,B,C}'s header files and.afiles in order to link correctly. Once you've done this your duplicate symbols will disappear. - trojanfoe