Level of difficulty: Easy,
Approximate time required: 15 minutes
Introduction
Swift is an open source programming language developed by Apple. It’s a fast and interactive programming language to write software for phones, desktops and servers.
In this tutorial, we will learn how to Install Swift on your Debian 10 Buster Linux server.
Prerequisites
- A Debian 10 server
- A sudo user
- A terminal access to Debian 9
Step 1 – Update packages on your Debian 10 system
You can run the following command to update your packages:
sudo apt update
The above command will update packages on your Debian 10 server.
Step 2 – Install the required dependencies
Install the required dependencies on your Debian 10 server by running the following command:
sudo apt-get install libncurses5 clang libcurl4 libpython2.7 libpython2.7-dev
Type Y if asked for confirmation.
This will install the required dependencies for Swift on your Debian 10 server.
Step 3 – Install Swift on your Debian Strech
There is no official download of Swift for Debian 10, however you can use the link provided for installation on Ubuntu 18.04. At the time of writing this article, the latest version of Swift available is 5.1.3
You can use the following command, to get the archive of the latest version of Swift:
wget https://swift.org/builds/swift-5.1.3-release/ubuntu1804/swift-5.1.3-RELEASE/swift-5.1.3-RELEASE-ubuntu18.04.tar.gz
After the download is completed successfully, extract the downloaded archive.
tar xzf swift-5.1.3-RELEASE-ubuntu18.04.tar.gz
Then move the extracted folder to opt directory
sudo mv swift-5.1.3-RELEASE-ubuntu18.04 /opt/swift/
Step 4 – Configure PATH environment variable
You will also need to add the swift installation path to your systems PATH environment variable. You can do so by running the following commands:
echo "export PATH=/opt/swift/usr/bin:$PATH" >> ~/.bashrc source ~/.bashrc
Step 5 – Verifying the Install
To verify Swift has been successfully installed and configured,type:
swift -version
Expected output of a successful install:
Swift version 5.1.3 (swift-5.1.3-RELEASE) Target: x86_64-unknown-linux-gnu
Conclusion
Congrats on Installing Swift on your Debian 10 server!
Please feel free to leave a comment!
When installing Swift 5.5.5 (current version), I get:
swift: error while loading shared libraries: libedit.so.2: cannot open shared object file: No such file or directory
Any ideas how to fix this?
This might be because you are missing some dependency.
That should be 5.2.5
You can check out this post for installing Swift 5.2.5 on Debian 10.
https://linuxs.info/how-to-install-swift-5-2-on-debian-10-buster/