Dynamic library dependecy of a dynamic library is not embedded when building in Xcode, causing "image not found" errors

Hello,

I'm not sure if this is a bug, a known limitation or a user error on my part, but this is reproducing in Xcode 11 and Xcode 12 betas.

I have package A, which is a dynamic framework, and package B, which is dependent on package A.
When building for simulator in Xcode, the app deceptively launches with debugger attached. However running the app produces the following error:

Dyld Error Message:
Library not loaded: @rpath/A.framework/A
Referenced from: /.../Example.app/Example
Reason: image not found

Looking at the produced app bundle, indeed there is a Frameworks/B.framework, but no Frameworks/B.framework/Frameworks/A.framework, causing the issue.

Any assistance?
Thanks

This does sound like a bug to me.

Hello,

Where and how should I report this?
I worked around this by creating a static target as well, and using that, but it's less than optimal for my needs.

Thank you

If you're seeing an issue in Xcode, I would always report through http://feedbackassistant.apple.com

1 Like

Been running into this a lot with SwiftUI previews being broken because any non-embedded dynamic library targets that are defined by SPM packages, can't ever be found. This has forced us to have to embed them everywhere. Sent a bug report.

It would be awfully nice if Apple were to prioritize addressing these kinds of issues :D

Update:

I think this is due to the existing version of Carthage, which makes "fat" frameworks that must be "lipo'd" before they can be embedded. Xcode started being more picky about this lately, and the solution is to migrate to XCFrameworks for embedded binaries. Carthage has a new version that makes XCFrameworks, which isn't released quite yet but, we've been testing it, and it does fix our playgrounds and previews. I just wish the error messages we got were more descriptive so we could've realized that this was the problem much earlier!

2 Likes