Xcode / SPM integration issue—Xcode bundles frameworks into Swift Package frameworks that shouldn't have them

We are facing a very similar problem but with Extension targets.
Despite having "Do not embed" configured, Xcode embeds frameworks built from Swift packages into extension bundles.

Our setup is as follows:

  • :file_folder: Workspace
    • :hammer: App Project
      • :dart: App Target
      • :dart: Extension Target
    • :toolbox: Framework Project
    • :package: Swift Package (libaryType: .dynamic)

The app target uses the framework ("Link and Embed") and the Swift Package ("Link and Embed"). It also embeds the extension.
The extension uses the Framework ("Do not Embed") and the Swift Package ("Do not Embed").
The framework uses the Swift Package ("Do not Embed").
The Swift Package is a "leaf" dependency.

When building and running the app target, everything works as expected but when trying to upload the app to App Store Connect, we are get multiple ITMS errors referring to the extension. (ITMS-90206: "Invalid Bundle. The bundle contains invalid file 'Framework'", ITMS-90205: "Invalid Bundle. The bundle contains disallowed nested frameworks.", ITMS-90685: "CFBundleIdentifier Collision")

When inspecting the Contents of our .appex, it contains a .framework bundle under /Frameworks.
I double checked all involved build phases to ensure that no "Copy" phase is placing the SPM framework in anything except the main App Target.
When investigating the build output, I can find the (unwanted) embed step:

PBXCp /BuildProductsPath/Release-iphoneos/SPMBased.framework /UninstalledProducts/iphoneos/Extension.appex/Frameworks/SPMBased.framework (in target 'Intents Extension' from project 'for iOS')
    cd ~/Projects/App
    builtin-copy -resolve-src-symlinks /BuildProductsPath/Release-iphoneos/SPMBased.framework /UninstalledProducts/iphoneos/Extension.appex/Frameworks

By manually removing the /Frameworks folder, the ITMS errors go away - but this doesn't sound like the correct solution to this problem. Does anyone have a more elegant workaround? Or an idea why Xcode thinks it has to embed the SPM package products into the extension?

This would lead to duplicate symbol errors when statically linking the Swift package in e.g. an app target that links a framework which also (statically) links the same Swift package.

2 Likes