Understanding .swiftmodule and SDK compatibility on macOS

.swiftmodule files are incredibly fragile. They are only designed to be read by the exact compiler binary that produced them. Additionally, other .swiftmodule files that were inputs to compilation when the module was produced must be accessible and unmodified, which means they can't be distributed to an environment with a different SDK. The way I think of .swiftmodule files is that they are basically in-memory caches of the compiler's representation of the module for a single compilation. They just happen to get serialized to disk because compilation usually requires multiple compiler invocations to cooperate with each other.

4 Likes