Step 1 - System Update and Install curl
First run a system update and upgrade.
sudo apt update && sudo apt upgrade
Then install curl.
sudo apt install curl
Step 2 - Run the quick install script
curl -s https://archive.swiftlang.xyz/install.sh | sudo bash
The installer script will automatically detect whether your system is compatible with the repository.
Step 3 -Choose which version of Swift to install
If your system is compatible you will be presented with a menu which will allow you to choose which version of swift is installed.
1) latest - This will update to the latest release of Swift available
2) developer - Swift developer builds - this will update to the latest developer build available
3) Swift version 5.3.* - this will update to the latest point release of Swift 5.3
4) Swift version 5.4.* - this will update to the latest point release of Swift 5.4
5) Swift version 5.5.* - this will update to the latest point release of Swift 5.5
NOTE 1: The number of different versions of swift available will differ depending on the distribution/version.
NOTE 2: If installing on Raspberry Pi OS/Raspbian the only swift version available at the moment is swift-5.1.5 so there will be no menu presented
Step 4 - Install Swift
sudo apt install swiftlang
Step 5 - Check Swift version