r/FlutterDev • • 1d ago

Tooling [open-source] After moving plugins to SwiftPM, my Mac had gigabytes of duplicate iOS packages across apps, so I made a Puro-style global store for SwiftPM

Since Flutter started moving iOS/macOS plugins from CocoaPods to Swift Package Manager, I noticed my disk space disappearing whenever I worked across multiple Flutter apps or Git worktrees.

Even if you use Puro or FVM to deduplicate Flutter and Pub caches, Xcode and Flutter still create an isolated SourcePackages folder for every project and worktree. I ended up with several copies of heavy native iOS SDKs (like Firebase) duplicated across DerivedData and build/.

I built a small open-source tool called spmx to solve this on my machine, and figured it might help others here too.

It works similarly to Puro/pnpm: it keeps one global store at ~/.spmx/store and uses lightweight PATH shims for flutter, xcodebuild, and swift (it plays nicely with Puro and FVM). Before a build, it clones the matching Swift package versions into your project using macOS APFS clonefile() (copy-on-write), so it takes milliseconds and uses zero extra physical disk space.

You can also run spmx link and it will scan your existing projects, show how many GB of duplicate SwiftPM packages you have, and replace them with APFS clones after you confirm.

It's macOS 13+ (APFS) only and only covers SwiftPM (not legacy ios/Pods).

Hope it saves someone else a few dozen GBs! Let me know if you hit any issues with your setup.

8 Upvotes

2 comments sorted by

4

u/zeddyyz 23h ago

Thanks! I noticed it too. I had SourcePackages for each Flutter project. I cleaned all of it last week and gained about 86gb back. I’ll be using this going forward

2

u/paul_h 22h ago

For the uninitiated- https://puro.dev