The Linux operating system is a dominant force in the world of backend servers, so to be of any use for server-side development, Swift needs to be available on Linux. Fortunately, part of the open source release of Swift includes the Swift toolchain on Linux. Let's get it up and running with a "Hello World" program in Swift on Linux.
Getting started
This recipe will use Ubuntu 20.04, as this is a very popular and widely used Linux distribution, and 20.04 is the latest Long-Term Support (LTS) version. Additionally, pre-built binaries of the Swift toolchain are provided for this distribution by the Swift open source team. As a Mac user, I have tested this process on an instance of Ubuntu, running in the VirtualBox virtualization environment, but there should be no difference when running on bare metal.
How to do it...
Let's install the Swift toolchain and run our first Swift code on Linux:
- We need to install some dependencies related to the compiler...