Discover more from roger.ml
How to install Swift 5.8 in a Debian Distro
The official Swift.org Get Started page doesn't show how to install Swift in unsupported distros, like Debian. This guide will show how easy it is!
Today’s how-to guide will be quite short and simple. If you’re here, chances are you’re running a Debian distro and struggled to find Swift installation steps in Swift’s Get Started official page. Follow the steps below (tested only in Debian 11) to install Swift and be able to run Swift code in your distro:
Update your packages:
sudo apt update
Install required dependencies:
sudo apt-get install libncurses5 clang libcurl4 libpython2.7 libpython2.7-dev
When being asked if you want to continue, press Y and Enter.
Find the Swift version you want to install in Swift.org’s Official Download page. At the time of writing, the latest version available was Swift 5.8, so I went with that.
Right click on x86_64 for the row Ubuntu 18.04 and copy the link. In this case, this is what I got: https://download.swift.org/swift-5.8-release/ubuntu1804/swift-5.8-RELEASE/swift-5.8-RELEASE-ubuntu18.04.tar.gz
Download the tar.gz in your Debian distro:
Extract the downloaded package:
tar xzf swift-5.8-RELEASE-ubuntu18.04.tar.gz
Move Swift’s binary to /opt/
sudo mv swift-5.8-RELEASE-ubuntu18.04 /opt/swift/
Configure your PATH environment variable:
echo "export PATH=/opt/swift/usr/bin:$PATH" >> ~/.bashrc
This will modify your ~/.bashrc file to include the path of the Swift executable you just installed.
Apply your changes in your current shell session via:
Verify if your installation succeeded:
You should see something like this:
Swift version 5.8 (swift-5.8-RELEASE) Target: x86_64-unknown-linux-gnu
Installing Swift on a Debian server may seem daunting at first, but by following the step-by-step article, you can easily set up a functional Swift environment in no time! 😉
Thanks for reading roger.ml! Subscribe for free to receive new posts and support my work.