Library not loaded with multiple level nested frameworks on MacOS

I have a MacOS app with a Framework (FrameA) inside. In this FrameA there is a compiled Framework (FrameB).

The error is:

Library not loaded: @loader_path/../Frameworks/FrameB.framework/Versions/A/FrameB

Referenced from: /Users/myUsername/Desktop/AppName.app/Contents/Frameworks/FrameA.framework/Versions/A/FrameA

Reason: tried: '/Users/myUsername/Desktop/AppName.app/Contents/Frameworks/FrameA.framework/Versions/A/../Frameworks/FrameB.framework/Versions/A/FrameB' (no such file), '/Library/Frameworks/FrameB.framework/Versions/A/FrameB' (no such file), '/System/Library/Frameworks/FrameB.framework/Versions/A/FrameB' (no such file)

I have try in the FrameA to embed FrameB but it can't find it because of the path. There is always a /../ and this is the problem because it go one folder back. It should not.

You can see the problem in this part of the error: FrameA.framework/Versions/A/../Frameworks

When i try to edit the runpath on FrameB, the app still seach on the same place. It has not effect whatever i change there.

If i change the runpath of the app to @executable_path/Frameworks then it can't find FrameA. This is expected but i don't understand why it ignore what i write in the runtime of FrameA.

Another try was to not embed FrameB into FrameA but directly into the App. The App (exported) still complain and want to seach FrameB after the path of FrameA. But in this test FrameB was no more embed into FrameA.

In my App runpath i have:

$(inherited)
@executable_path/../Frameworks
@loader_path/Frameworks

In the FrameA runpath i have (its completly ignored in any case):

$(inherited)
@executable_path/Frameworks
@loader_path/Frameworks

When i look into the exported app, the FrameB is on the place wanted for both try. Only the path to search it is wrong with this /../ in the middle of the path.

How can i fix this ?

  • I just have found something, if I change the mach-O-type of FrameB from dynamic to static then everything is ok except the submission to the Apple Store. I get a code signature error: Invalid Code Signing. The executable 'com.hb.app.pkg/Payload/Appname.app/Contents/Frameworks/FrameA.framework/Versions/A/FrameA' must be signed with the certificate that is contained in the provisioning profile

Add a Comment

Replies

I don’t have time to work through your specific case here on DevForums (if you want dedicated, one-on-one help with this, open a DTS tech support incident) but my general advice on this topic is:

  1. Try to avoid nested frameworks. It doesn’t work at all on iOS and its descendents, and even on macOS you can run into snags.

  2. Use rpath-relative references for everything. Embedding Nonstandard Code Structures in a Bundle has some concrete examples of this.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

  • @eskimo on iOS I can build the same app without nesting the frameworks but macOS FrameworkA still want to search FrameworkB in it's subfolders. I don't know why. If framework A could use the root level Framework from the app it would work

Add a Comment