We have a Cocoa app that makes use of the R framework. Our intention is NOT to ship R with the app, as users will likely have their own version installed locally. The question we have is how to properly weak link against a framework that has multiple versions.
We're weak linking against it:
- Framework set to
optional
in linked binaries - Added as
-weak_framework
in build settings > other linker flags - We do the usual "class exists" detection in code before attempting to use R.
Here's what happens:
- If the same version of R we linked against is installed, everything works fine.
- If R is not installed, everything is fine. We detect the absence and it gracefully fails.
- Our trouble is when we link against a version (let's say 3.1) and the user has a different version (let's say 3.2). Then we get the error
can't resolve symbol (some sybmol) in (my app) because dependent dylib #1 could not be loaded
.
I guess this makes sense as we built against 3.1 and it's not there - 3.2 is. I'm just unclear on how to approach properly weak linking against an external library like this and allowing it to work with a different version. Or I'm completely missing the boat on how to weak link entirely. Which is entirely possible.
Any guidance very much appreciated.
Thank you