Also available via O’Reilly’s Safari, if you have a subscription (a free trial is available!)
The registration period for this training has now passed! Follow me on Twitter, or check back here to keep up to date with future training.
Included with your Safari subscription (or free trial!)i
I’ve been working with Swift for Linux, as part of a bunch of teaching material, as well as some conference talks that we’re working on. It’s not super easy to figure out, from searching, the best way to install Swift and Linux, if you’re a Mac user who wants to have a go with it. Here’s what I’ve found.
As it turns out, after extensive research, my feeling is that the best way to run Swift on Linux (on a Mac) is using Vagrant and VirtualBox. I’ve looked at a variety of options, including setting it up manually in a VM, using Docker for Mac, and so on, but this turned out to be the easiest way to do it, and maintain it.
To get Swift on Linux running, on your Mac:
- Download and install VirtualBox.
- Download and install Vagrant.
- Make sure you have Git installed, and clone the following repository: https://github.com/IBM-Swift/vagrant-ubuntu-swift-dev.git
- Once you’ve cloned the repository, change directory into it: vagrant-ubuntu-swift-dev
- Run the command: vagrant up
- Wait. The vagrantfile included in the repository you cloned, which tells Vagrant what to do, downloads Ubuntu 15.10, the Swift prerequisites, the prerequisites for libdispatch, the Swift concurrency library, the Sphinx documentation system, and then clones the Swift repository and creates a script that allows you to build Swift. (This might take a while, and will download a few gigabytes of stuff.)
- Once Vagrant is done, you can run the following command to connect to the Linux installation: vagrant ssh
- Then, once in Linux, run the following script to build Swift: /vagrant/swift-dev/swift/utils/build-script (This might also take a while, depending on the speed/capabilities of your computer.)
- You can then run the following command to verify Swift is up and running: swift –version
- You can then create some .swift files, and compile them with the swiftc command.
Easy! Hope that was helpful to someone.