Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nested Cocoa Touch frameworks

I'm looking for a way to be able to produce frameworks, which have sub-frameworks, that do not interfere with each other at runtime. The illustration below describes the idea best.

enter image description here

Assume each version of JSON Parser framework is incompatible with the other.

I've been trying a ton of approaches to achieve the above, but failed each time. The most promising one were umbrella frameworks, but not only does Apple discourage their usage (it's not clear to me why), but also they did not seem to work as expected.

What happens is, if I create an App with an embedded Framework A which itself has JSON Parser framework v1.0 embedded, all seems to work just fine. But as soon as I add JSON Parser framework v3.0 to the App and link the App against it, Framework A starts to use the JSON Parser framework v3.0 at runtime instead of v1.0 which resides inside it. And assuming they are incompatible with each other, this can break Framework A.

Same goes for adding Framework B but which implementation is chosen at runtime seems to be random.

Is it possible to create Framework A that has an embedded JSON Parser framework v1.0 and is safe to use in such scenario? I find it hard to believe there is no way to achieve that, but I can't find a way to get it to work, and began wondering if it's in fact possible :(

like image 753
Bartek Chlebek Avatar asked Oct 19 '14 04:10

Bartek Chlebek


1 Answers

You do not give much detail about how you build your frameworks, so this is just a shot in the dark.

I assume that you embedded frameworks "Dynamic library install name base" setting is set to @rpath. Then, in your embedding framework, remove the @executable_path related option from the "Runpath search path" setting (this is the app, and that is the reason why it finds the "global" framework first). This should make things work as you expect.

Another approach you could take into account is bundling the 3 versions of the framework you are using in a single framework bundle.

Finally, you could also consider linking manually (see this post, where the _loadPluginAtLocation method is defined).

Hope this helps.

like image 129
sergio Avatar answered Sep 30 '22 14:09

sergio