Incremental builds with Swift Package Manager and Linux / Docker

I am not sure I understand the question.

These cache mounts are used when building images (eg: they mount the cached folder during a RUN command in a dockerfile). So you could use it when building an new image for a dev container.

If you are thinking about caching the build artifacts for a package you open in a dev container, these do not apply.

However, as long as you are using the same container, your .build folder should stay there without any additional tricks. I guess if you wanted to keep the .build folder on the host machine (surviving between different containers) you could use "normal" bind mounts when spinning up the dev container - not sure how to configure this in vscode though.

edit: actually, I think vscode mounts your project's folder anyway, so you should the build cache in your local file system just as normal.

yes, this is what i am doing, the problem is every time the container restarts, the build cache gets invalidated for some reason. so incremental builds do not happen, even though all the artifacts are still present. this has a truly terrible interaction with macros and swift syntax, which takes forever to build.

Which version of Swift can you reproduce this with? A change that potentially fixes this should be available in 5.10 and main branch development snapshots.

5.9.2, which is the most recent version of swift i have been able to compile our code with. (there are many bugs remaining in the 5.10 compiler that are preventing us from upgrading.) i suppose we’ll just have to tough it out until 5.10 is release-ready.