Swift Debian 8 (Jessie)
Swift, Apples new programming language, to take over for Objective C has been open source for some time now. It only took at short time before it was available for various Linux Distros. The latest Swift version in the official Debian repos are 2.3.1. If you want version 3.x of swift Debian you need download and install it your self. Here is how to do it.
Use sudo or root to create directories and install Swift.
We will install Swift Debian in the /opt/swift/build folder. So first:
Then create the new folder for our Swift build.
mkdir -p swift/build
Change to the new directory before we download Swift.
Download the swift build from swift.org
The Swift Debian is still compressed, so we need to extract it. Make sure you downloaded the file to /opt/swift/build directory.
tar zxvf swift-3.0.2-RELEASE-ubuntu14.04
Now we need to make sure our system knows where the swift compiler is stored. For immediate effect you can paste this line.
But once you logged out, that setting will be gone. To make that permanent go to your home folder. Once back in your home folder (/home/what-ever-your-user-is-named), you want to edit the .profile file.
And paste this in at the end of the file.
To make sure it works, you can disconnect or log out (if it is a local system) and log back in. Try to type in swift and press enter. The swift console should now open. You might run into some errors if you try to compile anything now. So we need to install a bunch of packages. Install these packages by typing (or copy paste)
apt-get install curl gcc python-dev python-pip libffi-dev python-setuptools sqlite3 git-core git cmake ninja-build clang uuid-dev libicu-dev icu-devtools libbsd-dev libedit-dev libxml2-dev libsqlite3-dev swig libpython-dev libncurses5-dev pkg-config
Now your system should be able to compile and make executable files from swift source codes. However if you are new to swift there is one thing you need to know. Create a folder for each project you make. Because your main source file needs to be called main.swift. If not the compiler will return error code 1.
You are now ready to use both the swift console and compile your files. Give it a test.
Create a folder and create main.swift And here is short sample file you can try to compile.
let message = “Hello Debian World”
Compile the file by typing
And run the file by typing