11
votes

I have a dynamic framework which links against Google Maps (which is, as far as I see it, still kind of a static library, if not exactly that, just with a framework wrapper).

The problem is that the framework links against the static library and also seems to include its code directly, as I don't need to link or embed Google Maps in the app that uses the framework and everything works fine. Except if I work with Google Maps inside the app as well.

Either I get "undefined symbols for architecture XY" during the compile phase, or I link Google Maps against it and then I get a wall of warnings in the debug-console during app-launch like:

Class GMSPolyline2D is implemented in both /.../Build/Products/Debug-iphonesimulator/MyFramework.framework/MyFramework and /..../Bundle/Application/7C73324B-4A42-4063-98AA-879345997DE6/MyApp.app/MyApp. One of the two will be used. Which one is undefined.

Is there any way to only link against Google Maps in the framework, but NOT to include the symbols in the framework-product as well? It works for dynamic frameworks, but static libraries seem to be just included. I already tried weak-linking with -weak_framework and -weak_library, but it does not seem to work.

Actually, I could not make Xcode find the GoogleMaps binary for -weak_library inside its framework dir, even with directly linking inside the .framework folder as Library Search Path.

Since I am the only user of my framework I can enforce that every app that uses the framework DOES include the Google Maps framework. So far the app works fine except the warnings (and so far it does not matter which of both classes is used at runtime, since both should be the same). However, I would sleep better if there was a nicer solution :)


Edit: I could get -weak_library to work by just handing over the absolute path directly in the linker-flag section instead of using the Library Search Path setting. However, the problem still remains, obviously it is still included in the framework.

1
Found a similar problem, with kind of a solution, but it seems to be more of a workaround. I will consider that, but if anyone has a cleaner idea, I would appreciate it. stackoverflow.com/a/29603185/5460596Luke Schwoebel
Have you found any solution for this ??Alok Rao
Have you found a solution for this?Cosmin
Not a "solution" for the original problem, but I converted the framework back to a static library that is linked only at its final targetLuke Schwoebel

1 Answers

1
votes

Don't Do Dat

The best practice is to place all your Google Maps-dependent code in a separate library that links to both your library and the Google Maps static library.

(Credit: Robert Napier's answer to How to compile static library that includes optional classes that depend on a third party library