Nested Cocoa Touch Frames

I am looking for a way to create frameworks that have substructures that do not interfere with each other at runtime. The illustration below describes the idea better.

enter image description here

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

I tried a lot of approaches to achieve the above, but failed every time. The umbrella frames were the most promising, but not only did Apple prevent their use (I donโ€™t understand why), but they didnโ€™t seem to be working properly.

What happens if I create an application with built-in Framework A , which itself has built-in JSON Parser framework v1.0 , everything seems to work fine. But as soon as I add the JSON Parser framework v3.0 to the application and bind the application to it, Framework A starts using the JSON Parser framework v3. 0 at runtime, not v1.0 , which is inside it. And assuming they are incompatible with each other, this could break Framework A.

The same goes for adding Framework B , but which implementation is chosen at runtime seems random.

Is it possible to create Framework A with the built-in JSON Parser framework v1.0 and is it safe to use in such a scenario? Itโ€™s hard for me to believe that this cannot be achieved, but I canโ€™t find a way to make it work, and began to wonder if this is actually possible :(

+6
source share
1 answer

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

I assume that for the built-in frameworks "Basic installation for installing the dynamic library" @rpath is installed. Then, in your deployment infrastructure, remove the @executable_path parameter from the "Launch Path Path" parameter (this is the application, and that is why it first finds a "global" structure). This should do everything as you expect.

Another approach that you can take into account is to combine the three versions of the framework that you use in a single framework package .

Finally, you can also consider manually linking (see this post for the _loadPluginAtLocation method).

Hope this helps.

+2
source

Source: https://habr.com/ru/post/976924/


All Articles