r/Xcode • u/suyashsrijan • 1d ago
I made a tool to share Xcode build caches across git worktrees
I made this for personal use but I thought I'd make it available for others too.
Basically I have a 512GB Mac and I am often very close to running out of disk space on it. I switch worktrees a lot when I'm reviewing or testing changes and I end up with a separate DerivedData or .build folder for each one. I also spend a few minutes rebuilding the same deps whenever I build in a fresh worktree.
So I wrote a tool lets my worktrees share build caches, called Warm: https://github.com/theblixguy/warm-worktrees
The core idea here is to take advantage of a feature called block cloning on your filesystem. The tool uses it so copies of the build caches share disk space until their files change and only those changes occupy any additional disk space. If a dependency changes then Xcode can just fetch or rebuild what it needs and then reuse the rest.
Here's a graph to illustrate the improvements:

Now if you're using a different build system like Bazel or etc you probably don't need this tool as they already offer a shared cache feature, but I didn't want to change build systems nor want to make others do it.
This is also a general-purpose, cross-platform (macOS and Linux) tool so you can use it with Xcode, SwiftPM, etc or with other languages like Rust, TypeScript and etc so it's a single tool across all your various projects. It's highly customisable as well and can be easily integrated into your workflows, especially if you're using AI agents.
If you have any thoughts or feedback or if this tool helps you please let me know, thanks!
1
u/dawedev 13h ago
How do you clean up when a worktree gets removed? With clones it's hard to tell how much space deleting one actually frees, since du counts the shared blocks in every copy.
2
u/builtinswift 16h ago
using the filesystem instead of switching build systems, smart