Swift binary with embedded runtime and standard library?

Hi!

On Windows, unfortunately, the only option is something similar to macOS - you need to have the runtime installed. Going into the details of why that is required could get long and would be best to do as a long winded post on its own (basically, static linking on Windows doesn't work with Swift - somewhat intentionally).

For Linux and Android, it is possible to statically link the runtime and its dependencies.

In both of these cases, were you to prefer the dynamic linking (which I highly recommend), you would need the swift standard library (and runtime which is part of the standard library) and its dependencies (which is pretty much ICU IIRC).

For non-Windows, non-macOS targets, yes, it is possible. You will need to generate a statically linked binary which will link everything (including the C library, math library, Swift library, and ICU).

IIRC, you would do -static-stdlib -emit-executable to get that working.

@drexin and @spevans may have additional context on this which may have slipped my mind.

Saleem