Xcode not copying frameworks Swift package with binary target if only included from app extension

I have a Swift Package that includes XCFrameworks which are exported as binary targets. If I include any of the product in Frameworks and Libraries section of a notification service extension target, build succeeds while the extension crashes with dynamic linker error:

Library not loaded: @rpath/MoEngageRichNotification.framework/MoEngageRichNotification

My workaround is to include the same product in app target's Frameworks and Libraries section and add @executable_path/../../Frameworks to LD_RUNPATH_SEARCH_PATHS settings for extension target.

Is this a known limitation of XCode when using SPM?

This seems like correct behaviour to me. On iOS, you’re only allowed to embed frameworks at the top level. If you have an app extension that accesses one of those frameworks, you need to add a reference to the rpath search path, just like you’ve done.

Placing Content in a Bundle is very clear about this design:

iOS and tvOS support frameworks and Swift system libraries at the topmost app level; a nested bundle, like an app extension, can’t include a framework.

Share and Enjoy

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

Xcode not copying frameworks Swift package with binary target if only included from app extension
 
 
Q