# Can't clear Swift build cache, and it keeps using an old commit of a dependency

**URL:** <https://answers.netlify.com/t/cant-clear-swift-build-cache-and-it-keeps-using-an-old-commit-of-a-dependency/32004>\
**Category:** Support\
**Tags:** building\
**Created:** [February 6, 2021, 10:47pm UTC](https://answers.netlify.com/t/cant-clear-swift-build-cache-and-it-keeps-using-an-old-commit-of-a-dependency/32004 "2021-02-06T22:47:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Loopwerk](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/loopwerk/32/24143_2.png) [@Loopwerk](https://answers.netlify.com/u/Loopwerk)\
**Post date:** [February 6, 2021, 10:47pm UTC](https://answers.netlify.com/t/cant-clear-swift-build-cache-and-it-keeps-using-an-old-commit-of-a-dependency/32004/1 "2021-02-06T22:47:03Z")

</div>

I’m trying to build a website from a PR, specifically this one: [Switching to Saga by kevinrenskers · Pull Request #2 · loopwerk/loopwerk.io · GitHub](https://github.com/loopwerk/loopwerk.io/pull/2). This is a Swift project that also depends on some Python packages. The problem is that this Swift package depends on another package, to a specific branch. And Netlify keeps checking out an older commit, not the latest commit of that branch.

This is my Package.swift:

```swift
// swift-tools-version:5.2
import PackageDescription

let package = Package(
  name: "Loopwerk",
  dependencies: [
    .package(name: "Saga", url: "https://github.com/loopwerk/Saga.git", .branch("SwiftMarkdown")),
  ],
  targets: [
    .target(
      name: "Loopwerk",
      dependencies: ["Saga"]),
  ]
)

```

When you look at [https://github.com/loopwerk/Saga/commits/SwiftMarkdown](https://github.com/loopwerk/Saga/commits/SwiftMarkdown), you can see that the latest commit has hash `192753e9475bff3ead679c83883f57ef3087ce5f`. Yet in the build log this error keeps happening:

```auto
9:54:46 PM: 5.2 has been installed.
9:54:46 PM: Using Swift version 5.2
9:54:46 PM: Building Swift Package
9:54:46 PM: Started restoring cached swift build
9:54:46 PM: Finished restoring cached swift build
9:54:48 PM: Fetching https://github.com/loopwerk/Saga.git
9:54:49 PM: https://github.com/loopwerk/Saga.git @ 99ae70723ac84ed96291f36e659e554ba5a0ed40: error: package at 'https://github.com/loopwerk/Saga.git' @ 99ae70723ac84ed96291f36e659e554ba5a0ed40 is using Swift tools version 5.3.0 but the installed version is 5.2.0
9:54:49 PM: Error building Swift package

```

Even when I re-run the build with the clean cache option, it keeps restoring the cached Swift build, and keeps using that `99ae70723ac84ed96291f36e659e554ba5a0ed40` commit.

---

<div class="post-metadata">

**Author:** ![Loopwerk](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/loopwerk/32/24143_2.png) [@Loopwerk](https://answers.netlify.com/u/Loopwerk)\
**Post date:** [February 6, 2021, 10:52pm UTC](https://answers.netlify.com/t/cant-clear-swift-build-cache-and-it-keeps-using-an-old-commit-of-a-dependency/32004/2 "2021-02-06T22:52:29Z")

</div>

It also redownloads Swift 5.2 (a 369M download, taking 40+ seconds) for each and every build. Is that expected? 🤔

---

<div class="post-metadata">

**Author:** ![Loopwerk](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/loopwerk/32/24143_2.png) [@Loopwerk](https://answers.netlify.com/u/Loopwerk)\
**Post date:** [February 7, 2021, 12:55pm UTC](https://answers.netlify.com/t/cant-clear-swift-build-cache-and-it-keeps-using-an-old-commit-of-a-dependency/32004/3 "2021-02-07T12:55:59Z")

</div>

Never mind, I found out what was causing it: Package.resolved was still pointing to that older release.

---

<div class="post-metadata">

**Author:** ![luke](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/luke/32/39_2.png) [@luke](https://answers.netlify.com/u/luke)\
**Post date:** [February 8, 2021, 4:41am UTC](https://answers.netlify.com/t/cant-clear-swift-build-cache-and-it-keeps-using-an-old-commit-of-a-dependency/32004/4 "2021-02-08T04:41:47Z")

</div>

Hi, @Loopwerk. Thanks for taking the time to loop back to share the solution you found.

This prevents the “denvercoder9” scenario and no one likes that:

> **[Wisdom of the Ancients](https://xkcd.com/979/)**
>
> All long help threads should have a sticky globally-editable post at the top saying 'DEAR PEOPLE FROM THE FUTURE: Here's what we've figured out so far ...'

Again, @Loopwerk. Thank you for taking the time to post the solution so future web searchers don’t yell at their monitors. 😉
