Swift Debian 8 (Jessie)

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:
cd /opt

Then create the new folder for our Swift build.
mkdir -p swift/build

Change to the new directory before we download Swift.
cd swift/build

Download the swift build from swift.org
wget https://swift.org/builds/swift-3.0.2-release/ubuntu1404/swift-3.0.2-RELEASE/swift-3.0.2-RELEASE-ubuntu14.04.tar.gz

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.
export PATH=/opt/swift/build/swift-3.0.2-RELEASE-ubuntu14.04/usr/bin:"${PATH}"

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.
vim .profile

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
swiftc main.swift

And run the file by typing

Happy coding

About Author

Related Posts

php8 gd

PHP8 gd Activate after installation

PHP8 GD activate after installation. GD doesn’t get activated by default. Not even a reboot after installation will activate it. So how do we do it? In…

Debian 12: linux-image-6.1.0-10amd64

Troubleshooting dependency issues in Debian 12: Resolving linux-image-6.1.0-10amd64 package dependency problems. If you installed the Debian 12 from the live image the issue is the raspi-firmware. Even…

OpenMediaVault default password

OpenMediaVault default password

OpenMediaVault default password is printed in the documentation. I did not see it the first time I installed it either. So I had to do some detective…

Debian change dns

Debian change DNS settings to a new DNS

Debian change DNS settings for speed improvement or privacy. It is really easy to do. So let us see how it’s done and get to it. The…

Upgrade debian 9 to debian 10

Upgrade Debian 9 to Debian 10

Upgrade Debian 9 to Debian 10 is very similar to upgrading previous versions. The only you need to do is change the sources to Buster instead of…

Debian 10 Static IP

Debian 10 Static IP

Debian 10 static IP works just like the previous version. They changed the naming of the network interfaces in Debian 9. However if you have upgraded from…

Leave a Reply