Swift is a safe, fast, expressive general-purpose programming language build for the software design patterns. It is best for the systems programming, to mobile and desktop applications. Swift provides a large number of features that make programming easier while giving the developer the control needed in a true systems programming language.
This tutorial will help you to install swift programming language on your Ubuntu and Debian system.
Step 1 – Prerequisites
Login to your Ubuntu system using SSH (Shell) access. Now install the required dependencies for swift installation on your system.
sudo apt-get install clang libicu-dev
On a fresh Ubuntu 16.04 install, I also needed to install following packages to work swift properly.
sudo apt-get install libcurl3 libpython2.7 libpython2.7-dev
Step 2 – Install Swift Ubuntu 16.04
First, import the swift GPG keys to validate packages on your system. This will help you to verify archive signature file.
wget -q -O - https://swift.org/keys/all-keys.asc | sudo gpg --import -
Now download the latest available swift release from its official site. You can use below command to download Swift 4.0.3 on Ubuntu 16.04 system.
wget https://swift.org/builds/swift-4.0.3-release/ubuntu1604/swift-4.0.3-RELEASE/swift-4.0.3-RELEASE-ubuntu16.04.tar.gz sudo tar xzf swift-4.0.3-RELEASE-ubuntu16.04.tar.gz mv swift-4.0.3-RELEASE-ubuntu16.04 /usr/share/swift
Also, configure the swift binary to system’s PATH environment variable.
echo "export PATH=/usr/share/swift/usr/bin:$PATH" >> ~/.bashrc source ~/.bashrc
Step 3 – Check Swift Version
Use the following commadn to check the current instaled Swift version on your system.
swift --version Swift version 4.0.3 (swift-4.0.3-RELEASE) Target: x86_64-unknown-linux-gnu
Step 4 – Swift REPL Examples
Just type swift on your system console and you will get Swift console. You can use this console for quick operations and for the learning purpose.
swift
Below example will store a single string in a variable and print the variable value using the Swift console.
Also, do some mathematical operations using Swift console.
1 Comment
Thanks. I have installed Swift 4 on my Ubuntu 16.04 desktop in 5 minute only…