- Setup the Linux Subsystem for Windows 10 Anniversary Edition
- Run
sudo apt-get install build-essential
(and optionallysudo apt-get install clang
) - Download, and Run swift! Note: for each of these links you can click or scroll down for more
https://www.youtube.com/embed/Z0PZc7WqPtE
And that's it.
Just note that both technologies are unstable as of September 2016
- Swift is a fairly immature programming language
- Due to the absence tools like a beautifier - though third-party tools such as Haaakon's SwiftFormat https://github.com/haaakon/SwiftFormat does the trick
- Due to missing tangible desires such as bug reports & support from fellow Windows users of Swift (of which there is none)
- And with breaking changes each major version of Swift (which might be why the Swift 1.0 code you found won't work on Swift 2.2 or even Swift 3.0 beta).
Setting up WSL
To set up the Windows subsystem for Linux, an official guide can be followed here: https://msdn.microsoft.com/en-us/commandline/wsl/install_guideHere's a summary:
- Start Menu -> Search "Turn Windows features on or off"
- Scroll Down to "Windows Subsystem for Linux (Beta)", and click the checkbox
- Restart your computer, it should display a screen along the lines of "Configuring Windows", similar to a Windows Update
- Once your computer has restarted, launch a normal Windows Command Prompt: Start Menu -> Search "Command Prompt" (or alternatively, cmd)
- Type the command "bash", and press enter
- Accept the T&C (or not, skipping this section and booting into Ubuntu is effectively the same)
- Wait for the ~200MB Ubuntu Subsystem Image to Download, Extract and Install
And that's it! A mini non-Linux environment within Windows. Similar to how OS X does it, only 10 years behind.
Takes around 30 minutes.
Those Linux commands
With how administrative/root privileges work in WSL, you don't need "su/sudo" to run what are normally root commands (if you've skipped setting up the root user).
apt-get install build-essential
should work on its own.The build-essential package is required to run Swift. Without it, Swift would just fail in executing scripts. Unfortunately, this is quite a large package on Ubuntu, and even on Windows its no exception.
So run the command and wait it out, a tip to speed up the process of downloading packages is shown in the video.
Running
apt-get install clang
allows for Swift code compilation support in Windows via swiftc (swiftc with build-essentials alone does not work). Interestingly the resulting binary that swiftc compiles is a native Linux/Ubuntu ELF instead of a Windows exe.
Takes around 30 minutes.
Swift
Download Swift from here: https://swift.org/download/, note that you'd want the Ubuntu 14.04 version, if still offered.Extract the archive just like you would on Ubuntu (or extract it using the Windows method, whichever you prefer), and run /usr/bin/swift through bash.
Takes around 10 minutes.
And that's it! Swift (the programming language) running on Windows 10 using the Windows Subsystem for Linux!
Although REPL doesn't really work, and you're not exactly working with native Windows goodness.