Run Linux Swift on your Mac or PC

Lars-Jørgen Kristiansen
1 min readDec 8, 2015

--

This is a quick and easy way to run Swift on Linux with your Mac or Windows PC. With this technique you can edit the source files with your favorite editor on your Mac or PC, and compile from within a Linux docker container.

Install Docker Toolkit if you don’t have it already.

  1. Open the Docker Quickstart Terminal app
  2. cd into your soruce code directory and create a docker-compose.yml file with this contents:
ubuntu-swift:
image: swiftdocker/swift
volumes:
- .:/code

This file tells docker-compose to set up one container called ubuntu-swift based on the swiftdocker/swift image.
swiftdocker/swift is a Ubuntu 14.04 image with swift installed.

The volumes section tells docker-compose to mount the curent directory to the /code directory inside the container.

3. Boot and run bash within the container by running:

docker-compose run ubunut-swift bash

4. type cd /code to change into the mounted source code directory.

You can now edit the source files on OS X, and compile on ubuntu inside the container.

--

--