swiftenv
swiftenv copied to clipboard
Support Windows binaries
The Swift toolchain recently added official support for Windows, so it would be nice to have swiftenv
support it. Or would that be impossible given that swiftenv
is written in Bash?
I don't think bash would be a blocker, bash is available on Windows. Installing other development tools such as git bring bash terminal along too.
At the moment, swiftenv should already work with Windows providing swift versions have been installed in ~/.swiftenv/versions/<version>
with a usr/bin
directory containing the binaries (custom installation). I would imagine that aliasing ~/.swiftenv/versions/5.3
to /c/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain
would allow using swiftenv with these Windows toolchains with prior versions of swiftenv.
I've taken a look at what it would take to support both installing from these new Windows binaries, and being able to switch between the versions and have a limited proof of concept working, however it would appear that it won't be possible to support these binaries in their current form due to the following:
- The installer appears to be GUI only (invoking it from terminal, even with --help and other flags launches GUI).
- Swift 5.3 is installed into
/c/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain
(these toolchain names do not appear to be unique nor contain version identifier unlike the macOS toolchains).
However given the caveats, installing the Swift package manually allows it to be known by swiftenv with a couple of minor changes to libexec/swiftenv-versions
and libexec/swiftenv-prefix
:
$ ./libexec/swiftenv versions
* system
unknown-Asserts-development
$ env SWIFT_VERSION=unknown-Asserts-development ./libexec/swiftenv prefix
/c/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain
$ env SWIFT_VERSION=unknown-Asserts-development ./libexec/swiftenv exec swift --version
compnerd.org Swift version 5.3 (swift-5.3-RELEASE)
Target: x86_64-unknown-windows-msvc