# \[Xcode 12.5 RC\] Duplicated artifacts of binary frameworks in DerivedData

**URL:** <https://forums.swift.org/t/xcode-12-5-rc-duplicated-artifacts-of-binary-frameworks-in-deriveddata/47589>\
**Category:** Using Swift\
**Tags:** bug, packagemanager, binary-framework, xcframework, sub-dependency\
**Created:** [April 21, 2021, 9:03am UTC](https://forums.swift.org/t/xcode-12-5-rc-duplicated-artifacts-of-binary-frameworks-in-deriveddata/47589 "2021-04-21T09:03:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![username0x0a](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/username0x0a/32/6485_2.png) [@username0x0a](https://forums.swift.org/u/username0x0a)\
**Post date:** [April 21, 2021, 9:03am UTC](https://forums.swift.org/t/xcode-12-5-rc-duplicated-artifacts-of-binary-frameworks-in-deriveddata/47589/1 "2021-04-21T09:03:30Z")

</div>

I've just rechecked a proposed use of binary packages in our project and found a weird behaviour of such artifacts checking in the `DerivedData` folder.

Imagine the following project structure:

```swift
App
- Places (local Swift package)
- CountryCodes (local Swift package)
- LocalizedStrings (local Swift package)
- CarrierProviding (local Swift package)
- ImageDownloader (local Swift package)
…
- ExternalDependencies (local Swift package)
  - Facebook SDK (binary xcframework dependency via HTTPS)
  - Firebase SDK (binary xcframework dependency via HTTPS)

```

Where:

- The `App` target depends on all of the mentioned local Swift packages
- `ExternalDependencies` is a wrapping package which contains external dependencies referenced via HTTPS URL link to a ZIP file

Binary xcframeworks are downloaded and extracted to a `DerivedData/APP/SourcePackages/artifacts` folder, yet not directly, but to a subfolder named by a package. 👍

I'd expect to either fetch all artifacts to be either downloaded side-by-side (workspace-wide, but that could be problematic with different packages requesting different versions, so that's not the case) or per-package (depending on which package actually calls for such binary artifacts – which I presume should be the case then). With this in mind, I'd expect to see a `ExternalDependencies` subfolder here which would contain all those referenced binary dependencies, downloaded and extracted, linked in the Workspace JSON file.

What actually happens is, all those binary packages are stored in an `artifacts` subfolder named by a _random_ one of the local Swift packages mentioned above, where none of those depends on either no or only another local Swift package (but never the `ExternalDependencies` one), but not on any binary dependency nor the `ExternalDependencies` package alone – that one is only linked by the `App` target.

What's worse, every time I close the project and reopen it, _ANOTHER_ folder in `artifacts` is created and the binaries are fetched again and again into multiple folders (named by unrelated SPM packages) every time on project opening.

The `App` target alone compiles fine, with every new project opening, the `workspace-state.json` file is updated with this newly created folder so the linking goes fine, but imagine we have ~27 local Swift packages to nicely separate code, having to download ~150–200MB of binary dependencies on every project open – that's over 5GBs of redundant files instead of just a single fetch. 🙈

Here's a conflicting, cleaned up `workspace-state.json` file, you can easily spot the duplicated references to same artifacts being linked to unrelated Swift packages instead of the right one.

[workspace-state.json](https://pastebin.com/mHrFwATj)

Here's how it looks in Finder:

 ![Screenshot 2021-04-21 at 16.14.42](https://global.discourse-cdn.com/swift/original/3X/3/d/3d8bfbc04aefb278e3f08444b8a39942f015e4d9.png)

Just tested and applies freshly to **Xcode 12.5 RC (12E262)**, first discovered in previous Beta 3.

Reported as `FB9084662`.

---

<div class="post-metadata">

**Author:** ![DevAndArtist](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/devandartist/32/287_2.png) [@DevAndArtist](https://forums.swift.org/u/DevAndArtist)\
**Post date:** [April 21, 2021, 10:40am UTC](https://forums.swift.org/t/xcode-12-5-rc-duplicated-artifacts-of-binary-frameworks-in-deriveddata/47589/2 "2021-04-21T10:40:36Z")

</div>

Moving this thread into #swift-users as this isn't strictly about SPM development.

Bugs can be discussed in the forums, but unlikely to be tracked unless they were reported using the Apple's feedback assistant for things that are not open source or at [bugs.swift.org](http://bugs.swift.org) for the open source related parts such as SPM.

---

<div class="post-metadata">

**Author:** ![username0x0a](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/username0x0a/32/6485_2.png) [@username0x0a](https://forums.swift.org/u/username0x0a)\
**Post date:** [April 21, 2021, 2:26pm UTC](https://forums.swift.org/t/xcode-12-5-rc-duplicated-artifacts-of-binary-frameworks-in-deriveddata/47589/3 "2021-04-21T14:26:57Z")

</div>

Thanks for alignment. 👍 I'm not really sure whether it's somehow touching the open-source part, but I've added a note about Apple Bug Tracker report.

Possibly Cc @NeoNacho with a kind request on helping 🤔 I'll be available for assistance in case of troubles with reproducing.

---

<div class="post-metadata">

**Author:** ![NeoNacho](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/neonacho/32/1368_2.png) [@NeoNacho](https://forums.swift.org/u/NeoNacho)\
**Post date:** [April 21, 2021, 5:15pm UTC](https://forums.swift.org/t/xcode-12-5-rc-duplicated-artifacts-of-binary-frameworks-in-deriveddata/47589/4 "2021-04-21T17:15:32Z")

</div>

Thanks for reporting this, I'll take a look. The intent was that the subfolder was named after the package containing the binary target, but seems like this isn't working as intended anymore.

---

<div class="post-metadata">

**Author:** ![username0x0a](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/username0x0a/32/6485_2.png) [@username0x0a](https://forums.swift.org/u/username0x0a)\
**Post date:** [April 22, 2021, 8:28am UTC](https://forums.swift.org/t/xcode-12-5-rc-duplicated-artifacts-of-binary-frameworks-in-deriveddata/47589/5 "2021-04-22T08:28:16Z")

</div>

Thank you! 👍 My teammate just found out that the binaries are downloaded to a proper `artifacts/ExternalDependencies` subfolder in Xcode 12.4, so this issue started misbehaving with the 12.5 cycle. ℹ

---

<div class="post-metadata">

**Author:** ![username0x0a](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/username0x0a/32/6485_2.png) [@username0x0a](https://forums.swift.org/u/username0x0a)\
**Post date:** [May 1, 2021, 7:45pm UTC](https://forums.swift.org/t/xcode-12-5-rc-duplicated-artifacts-of-binary-frameworks-in-deriveddata/47589/6 "2021-05-01T19:45:00Z")

</div>

I've got a feedback reply that it was not possible to reproduce the issue, so I've updated it with a demo workspace and a screen capture video demonstrating the issue. 👍

The demo workspace project is [also available here](https://github.com/username0x0a/xcode-12.5-binary-spm-artifacts-issue). 💡

---

<div class="post-metadata">

**Author:** ![NeoNacho](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/neonacho/32/1368_2.png) [@NeoNacho](https://forums.swift.org/u/NeoNacho)\
**Post date:** [May 4, 2021, 1:04am UTC](https://forums.swift.org/t/xcode-12-5-rc-duplicated-artifacts-of-binary-frameworks-in-deriveddata/47589/7 "2021-05-04T01:04:10Z")

</div>

Thanks for the demo workspace, much appreciated!
