Install Swift on Debian for Swift development.

A Comprehensive Guide to Install and Use Swift on Ubuntu: Easy Step-by-Step Instructions, PATH Exporting, and Missing Dependency Handling.

  • Table of contents

sudo apt-get update
sudo apt-get install libncurses5 clang libcurl4 libpython2.7 libpython2.7-dev wget

Download package

wget https://swift.org/builds/swift-5.4.1-release/ubuntu1804/swift-5.4.1-RELEASE/swift-5.4.1-RELEASE-ubuntu18.04.tar.gz
sudo mv swift*RELEASE* /opt/swift/

Export path

Add Swift to your PATH variable using your shell's config file.

Zsh

echo "export PATH=/opt/swift/usr/bin:$PATH" >> ~/.zshrc

Bash

echo "export PATH=/opt/swift/usr/bin:$PATH" >> ~/.bashrc

Open a new terminal and type swift --version to confirm.

Handle missing dependencies

If you see:

version `GLIBCXX_3.4.26' not found (required by swift)

Try these steps:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.9
sudo apt-get upgrade libstdc++6