Does Swift Package Manager have a local cache?
Asked Answered
E

2

9

Every time I load a new package, Xcode redownloads all dependencies from Github, instead of reusing some that I've already loaded for other projects.

For instance I would expect that when I reference .package(name: "SwiftyJSON", url: "https://github.com/SwiftyJSON/SwiftyJSON.git", from: "5.0.0") and when I have a matching package on my laptop, Xcode would not redownload the package.

Is it possible to configure Xcode to use a more aggressive caching strategy?

Elliotelliott answered 11/10, 2020 at 23:39 Comment(0)
U
14

From Xcode 12.5 the dependencies are cached in ~/Library/Caches/org.swift.swiftpm/

EDIT

Not the compiled dependencies but only the source (checkouts) are cached in this place. It seems we have to wait for yet another update until Apple offers a xcodebuild option to pass the build_path for the dependencies.

Ultraism answered 29/4, 2021 at 18:25 Comment(3)
This is great news!Elliotelliott
What about ~/Library/Developer/Xcode/DerivedData and .build/SourcePackages? What's the relationship between them?Conferva
Close XCode. rm -rfv ~/Library/Caches/org.swift.swiftpm/ and rm -rfv ~/Library/Developer/Xcode/DerivedData and rm -rfv <Project Path>/DerivedData Then open XCode is what workedStenograph
T
0

Deleting the whole SPM cache will make your life a nightmare as when you start reloading it, it'll download every single dependency, not a shallow checkout, but the whole GIT history of each single dependency! It's massive! If you do, be aware!

Have a look at this post: Why fetching packages using Swift Package Manager takes too much time?

I left whole night downloading and still failing

Talcahuano answered 14/6 at 8:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.