Short path to installing Swift in Linux and creating the first executable program.

Connect to the swift.org site, go to the download section and download the Ubuntu version package. Next on the page there are the installation instructions that I've reported here for simplicity. You need to have a couple of pre-installed packages:

$ sudo apt-get install clang libicu-dev

It is necessary to import the PGP keys:

$ wget -q -O - https://swift.org/keys/all-keys.asc | gpg --import -

And update the keys:

$ gpg --keyserver hkp://pool.sks-keyservers.net --refresh-keys Swift

Use the signature file to verify integrity of the downloaded file:

$ gpg --verify swift-<VERSION>-<PLATFORM>.tar.gz.sig

Place the Swift tar.gz file in the final directory (it can be your home) and then unzip it:

$ tar xzf swift-<VERSION>-<PLATFORM>.tar.gz

Swift is installed. You need to enter the toolchain in the PATH, the path indicated is to reach the directory /usr/bin in the Swift installation directory (the file that was previously unpacked):

$ export PATH=/path/to/usr/bin:"${PATH}"

For convenience, you should also include this line in .bashrc so that Swift shell is always found.

Try the installation just done by asking the compiler to return the version:

$ swift --version
Swift version 4.0.2 (swift-4.0.2-RELEASE)
Target: x86_64-unknown-linux-gnu

Hello World, we have to do it. The easiest way to test an instruction or instruction block is to use REPL (Read Eval Print Loop), this tool can suggest commands and highlight any errors. Type "swift" and press enter.

$ swift
Welcome to Swift version 4.0.2 (swift-4.0.2-RELEASE). Type :help for assistance.

The line number is displayed and it is suggested to type :help for help. To quit, you must type :quit.

1> let greetings = "Hello World"
greetings: String = "Hello World"
2> print(greetings)
Hello World

I've created constant greetings and I've printed it, displaying the string type is performed by REPL to indicate that it correctly interpreted the entered value.