Swift is a free and open source general purpose multi-paradigm programming language for iOS, macOS, other Apple platforms Linux and Windows. It is released under Apache License 2.0.
Install Swift Language on Ubuntu Linux
Open the terminal application (ctrl+alt+t) and run below command. It will install Clang compiler on your Ubuntu Linux system.
sudo apt install clang -y
Now download Swift using below command. Here we are downloading the latest Swift (version 5.10). You can check the latest Swift version and the file download url using below official Swift download page. You can select the latest available Ubuntu platform. At the time of writing latest Ubuntu platform for Swift is Ubuntu 22.04. (Note: But currently i am using Ubuntu 23.10)
wget https://download.swift.org/swift-5.10-release/ubuntu2204/swift-5.10-RELEASE/swift-5.10-RELEASE-ubuntu22.04.tar.gz
After the download, extract it using below tar command.
tar xzf swift-5.10-RELEASE-ubuntu22.04.tar.gz
Now move the extracted folder to /usr/share/swift using below command.
sudo mv swift-5.10-RELEASE-ubuntu22.04 /usr/share/swift
Now configure the Swift binary to the PATH environment variable of your Ubuntu. Run the following commands to do.
echo "export PATH=/usr/share/swift/usr/bin:$PATH" >> ~/.bashrc
source ~/.bashrc
You can verify the installed Swift using below command.
swift --version
swift