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

**URL:** <https://forums.swift.org/t/xcode-spm-integration-issue-xcode-bundles-frameworks-into-swift-package-frameworks-that-shouldnt-have-them/50119>\
**Category:** Using Swift\
**Tags:** packagemanager\
**Created:** [June 30, 2021, 6:07am UTC](https://forums.swift.org/t/xcode-spm-integration-issue-xcode-bundles-frameworks-into-swift-package-frameworks-that-shouldnt-have-them/50119 "2021-06-30T06:07:38Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![weichsel](https://avatars.discourse-cdn.com/v4/letter/w/7feea3/32.png) [@weichsel](https://forums.swift.org/u/weichsel)\
**Post date:** [September 20, 2021, 6:32pm UTC](https://forums.swift.org/t/xcode-spm-integration-issue-xcode-bundles-frameworks-into-swift-package-frameworks-that-shouldnt-have-them/50119/4 "2021-09-20T18:32:35Z")

</div>

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:

- 📁 Workspace
  - 🔨 App Project
    - 🎯 App Target
    - 🎯 Extension Target

  - 🧰 Framework Project
  - 📦 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:

```swift
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?

> [@surajbarkale](#):
>
> The App should only depend on the `AppFramework` with all dependencies listed in `Package.swift` . Make sure the targets within `AppFramework` are static. This somehow forces XCode to eliminate all of the duplicates.

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.

---

_[View the full topic](https://forums.swift.org/t/xcode-spm-integration-issue-xcode-bundles-frameworks-into-swift-package-frameworks-that-shouldnt-have-them/50119)._
