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.
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.
/dev/world/2016 tickets are now on sale! /dev/world is a fabulous iOS and OS X (and associated ecosystem) developer conference that played no small part in kickstarting many parts of my career, and for the last few years I’ve been helping to organise the event.
/dev/world/2016 runs in Melbourne on August 29-31, 2016. The conference covers developing on and for iOS and OS X, using Swift to Objective-C, and everything in between. We’re selling our best-priced early bird tickets right now over at devworld.com.au
The gist of it is: you’ll join us live online for a day of Swift programming, where we’ll teach you the language, how to use it for iOS (or OS X) programming, and where to learn more. Everyone will get a video of the training afterwards, as well as an ebook copy of our brand new Learning Swift book.