Hello, friends. In this post we will help you to install Swift on Ubuntu 20.04 If you are planning to develop applications for macOS or iOS from Linux, this post will help you a lot.
Swift is a general-purpose programming language built using a modern approach to safety, performance, and software design patterns. The goal of the Swift project is to create the best available language for uses ranging from systems programming to mobile and desktop apps, scaling up to cloud services. Most importantly, Swift is designed to make writing and maintaining correct programs easier for the developer
So, let’s get to work
The installation of this language is quite simple. First, update the entire distribution
sudo apt update sudo apt upgrade
Then you need to install some dependencies that are required to run Swift on Ubuntu 20.04.
sudo apt install clang libicu-dev libpython2.7-dev libtinfo5 libncurses5 libpython2.7 libz3-dev
Then, we will have the operating system ready for Swift.
You can download Siwft for Ubuntu 20.04 from this link or use the wget command. In case you use
wget, you need to check which is the latest stable version first.
After that, run:
cd /tmp wget -c https://swift.org/builds/swift-5.3.3-release/ubuntu2004/swift-5.3.3-RELEASE/swift-5.3.3-RELEASE-ubuntu20.04.tar.gz --2021-02-02 19:56:44-- https://swift.org/builds/swift-5.3.3-release/ubuntu2004/swift-5.3.3-RELEASE/swift-5.3.3-RELEASE-ubuntu20.04.tar.gz Resolving swift.org (swift.org)… 220.127.116.11 Connecting to swift.org (swift.org)|18.104.22.168|:443… connected. HTTP request sent, awaiting response… 200 OK Length: 411919110 (393M) [application/x-gzip] Saving to: ‘swift-5.3.3-RELEASE-ubuntu20.04.tar.gz’ swift-5.3.3-RELEASE-ubuntu20.04.tar.gz 100%[=====================================================================================>] 392.84M 8.35MB/s in 50s 2021-02-02 19:57:34 (7.87 MB/s) - ‘swift-5.3.3-RELEASE-ubuntu20.04.tar.gz’ saved [411919110/411919110]
As of today, the latest stable version of Swift for Ubuntu 20.04 is
5.3.3 when it changes, remember to modify the commands.
After that, decompress the file:
tar xzf swift-5.3.3-RELEASE-ubuntu20.04.tar.gz
It is convenient to move the folder to another location, which in this case will be
/usr/share/ but it can be another one.
sudo mv swift-5.3.3-RELEASE-ubuntu20.04 /usr/share/swift
Now to use Swift from any location at the prompt, you need to add that folder to the PATH.
echo "export PATH=/usr/share/swift/usr/bin:$PATH" >> ~/.bashrc
Apply the changes by running:
Now you can use Swift. Proof of this is that you can check the installed version.
swift -v Swift version 5.3.3 (swift-5.3.3-RELEASE) Target: x86_64-unknown-linux-gnu /usr/share/swift/usr/bin/lldb "--repl=-disable-objc-interop -color-diagnostics" Welcome to Swift version 5.3.3 (swift-5.3.3-RELEASE).
So, enjoy it.
Ubuntu is a system widely used by developers and many may want to make applications for macOS or iOS. That’s why Swift is available and you know how to install it step by step.