Chapter 2. Discovering New Territories – Linux at Last!

Until recently, developing for Swift meant you needed a Mac, loaded with the Xcode IDE. However, all of that changed when Apple open sourced the Swift programming language in December 2015. A brave new world has been opened to us as developers, as Swift can now run on Linux! In addition, you now have access to preview releases and have direct access to the development trunk from which you can download development snapshots (for example, non-official prebuilt binaries of Swift).

This is going to be a packed chapter, and I want to highlight what we will cover. My goal is to show you where to find the latest Swift source for both Mac and Linux. I will also provide instruction on how to use toolchains and explain how the Swift package manager works. Last, we will develop our first program on Linux.

In order to get started working with Swift 3, you need to download either a prebuilt binary (also known as a toolchain) or the source code to build the Swift library yourself. The Swift.org (https://swift.org) website hosts a Download section https://swift.org/download/ that maintains a list of releases, previews and snapshots:

  • Release builds: Maintains links to the current release and older official releases of Swift.
  • Preview builds: Contains links to developer previews, also known as seeds or betas. These binaries are not considered final releases but do provide a fairly stable version of the work completed to that date for upcoming releases.
  • Developer snapshots - Are pre-built binaries from the development branch. These builds contain the latest development changes and have gone through automated unit testing but are not guaranteed to be stable. Snapshot builds are not put through the full testing process.