13.5 C
Texas
angeloma
Senior Writer and partner

How to install Swift programming language on Ubuntu 20.04?

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

Install Swift on Ubuntu 20.04

The installation of this language is quite simple. First, update the entire distribution

- Advertisement -
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-06-25 18:12:42--  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)… 169.47.73.10
 Connecting to swift.org (swift.org)|169.47.73.10|:443… connected.
 HTTP request sent, awaiting response… 200 OK
 Length: 508207625 (485M) [application/x-gzip]
 Saving to: ‘swift-5.3.3-RELEASE-ubuntu20.04.tar.gz’
 swift-5.3.3-RELEASE-ubuntu20.04.tar.gz     100%[=====================================================================================>] 484.66M  8.50MB/s    in 59s     
 2021-06-25 18:13:41 (8.24 MB/s) - ‘swift-5.3.3-RELEASE-ubuntu20.04.tar.gz’ saved [508207625/508207625]

As of today, the latest stable version of Swift for Ubuntu 20.04 is 5.4.1 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:

source ~/.bashrc

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).
1.- Swift on Ubuntu 20.04
1.- Swift on Ubuntu 20.04

So, enjoy it.

Conclusion

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.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article