Swift is no longer tied to Apple-only workflows. On Linux it gives you the same compiler, package manager, and server-side tooling used for command-line apps, Vapor projects, and cross-platform development. To install Swift on Ubuntu Linux, the right method depends on your LTS release because Ubuntu 26.04 packages swiftlang, while Swift.org still targets Ubuntu 24.04 and 22.04 for its upstream toolchains.
That release split matters. Ubuntu 26.04 can install Swift directly from universe, but Ubuntu 24.04 and 22.04 need Swiftly or the official tarball. That gives you a complete path across all three supported Ubuntu LTS releases, from verification and a first Swift Package Manager project to troubleshooting, updates, and clean removal.
Install Swift on Ubuntu Linux
Three installation paths are available. Ubuntu 26.04 uses the swiftlang package, while Ubuntu 24.04 and 22.04 rely on Swift.org builds. On Ubuntu 24.04 and 22.04, do not use apt install swift for Apple’s language because that package name belongs to OpenStack Swift object storage.
| Method | Channel | Version | Updates | Best For |
|---|---|---|---|---|
| swiftlang | Ubuntu Universe | Distribution default | apt upgrade | Ubuntu 26.04 users who want a system-managed install |
| Swiftly | Swift.org | Latest stable upstream | swiftly update | Ubuntu 24.04 and 22.04 users who want the easiest upstream workflow |
| Official tarball | Swift.org | Latest stable upstream | Manual download | Ubuntu 24.04 and 22.04 users who want an upstream install without a manager |
Use swiftlang on Ubuntu 26.04, and use Swiftly on Ubuntu 24.04 or 22.04 unless you specifically want a manager-free tarball install. Ubuntu 26.04 currently ships Swift 6.1.x, while Swift.org’s Ubuntu 24.04 and 22.04 toolchains are already on Swift 6.2.x. Swiftly handled the compiler, Swift Package Manager, and CLI project builds cleanly on both older LTS releases, while the tarball method is useful when you want the same upstream toolchain under /opt without another layer on top.
These steps cover Ubuntu 26.04 LTS, 24.04 LTS, and 22.04 LTS. Swift.org has not published native Ubuntu 26.04 toolchains yet, so Swiftly exits with
Error: Unsupported Linux platformon Resolute and the upstream tarballs still target 24.04 or 22.04. Ubuntu 26.04 users should useswiftlangfor now, and this article will be updated when Swift.org adds native 26.04 support.
Update Ubuntu Before Installing Swift
Refresh the package index first so Ubuntu sees the latest repository metadata before you install Swift or any upstream prerequisites.
sudo apt update
Hit:1 http://au.archive.ubuntu.com/ubuntu resolute InRelease Hit:2 http://security.ubuntu.com/ubuntu resolute-security InRelease Reading package lists... Done
These commands use
sudofor tasks that need root privileges. If your account is not in the sudoers file yet, follow the guide on how to add a new user to sudoers on Ubuntu.
Install Swift from Ubuntu Repositories on Ubuntu 26.04
Ubuntu 26.04 packages Apple’s language as swiftlang in universe, which makes this the cleanest path on Resolute. The tested package download was about 558 MB and used roughly 2.5 GB after installation.
sudo apt install swiftlang
Check the compiler version once APT finishes.
swift --version
Swift version 6.1.3 (swift-6.1.3-RELEASE) Target: x86_64-pc-linux-gnu
If you want to confirm Ubuntu is using its own package source rather than an older manual install, check the package policy.
apt-cache policy swiftlang
swiftlang:
Installed: 6.1.3-4build1
Candidate: 6.1.3-4build1
Version table:
*** 6.1.3-4build1 500
500 http://au.archive.ubuntu.com/ubuntu resolute/universe amd64 Packages
100 /var/lib/dpkg/status
Install Swift upstream dependencies on Ubuntu 24.04 or 22.04
Swiftly and the official tarball both need a small set of Ubuntu development libraries. Desktop installs often already have some of them, but minimal and server images can still miss basics such as curl. The curl command guide for Linux explains the download flags used later if you want a closer breakdown.
Swift upstream dependencies on Ubuntu 24.04
Ubuntu 24.04 needs the following packages before you install Swift from Swift.org.
sudo apt install curl ca-certificates tar git gnupg2 libcurl4-openssl-dev libpython3-dev libxml2-dev libz3-dev pkg-config zlib1g-dev
Swift upstream dependencies on Ubuntu 22.04
Ubuntu 22.04 uses the same dependency set with one extra ncurses development package.
sudo apt install curl ca-certificates tar git gnupg2 libcurl4-openssl-dev libpython3-dev libxml2-dev libncurses-dev libz3-dev pkg-config zlib1g-dev
Swiftly still prints a stale
python3-lldb-13hint on Ubuntu 24.04, but Noble no longer ships that exact package name. That package set was enough forswift --version,swift package init, andswift runon Ubuntu 24.04.
Install Swift with Swiftly on Ubuntu 24.04 or 22.04
Swiftly is Swift.org’s official toolchain manager for Linux. It keeps the toolchain in your home directory, writes an environment file to ~/.local/share/swiftly/, and makes later updates easier than a manual tarball install.
Download the latest Swiftly release from Swift.org. The versionless URL always resolves to the current bootstrap archive for your architecture.
curl -fsSLO "https://download.swift.org/swiftly/linux/swiftly-$(uname -m).tar.gz"
Confirm the archive is in your current directory before extracting it.
ls -lh "swiftly-$(uname -m).tar.gz"
-rw-rw-r-- 1 joshua joshua 28M Mar 13 12:52 swiftly-x86_64.tar.gz
Extract the archive next. This creates a local swiftly binary in your current directory.
tar -xzf "swiftly-$(uname -m).tar.gz"
Confirm the extracted bootstrap binary is present before you run it.
ls -lh swiftly
-rwxrwxr-x 1 joshua joshua 72M Mar 13 12:52 swiftly
Initialize Swiftly after that. The installer writes its environment file under ~/.local/share/swiftly/, adds a line to ~/.profile, and downloads the current Swift toolchain automatically, so expect a download of roughly 960 MiB.
./swiftly init --assume-yes
Installing swiftly in /home/joshua/.local/share/swiftly/bin/swiftly... Fetching the latest stable Swift release... Installing Swift 6.2.4 Swift 6.2.4 is installed successfully!
Swiftly appends an environment line to ~/.profile. Load it in the current shell and clear Bash’s command cache so the new swift path is picked up immediately.
. "$HOME/.local/share/swiftly/env.sh"
hash -r
If you open a new terminal later, Ubuntu reads ~/.profile automatically and you should not need to run that command again.
Verify both the active compiler and the installed Swiftly toolchain list.
swift --version
Swift version 6.2.4 (swift-6.2.4-RELEASE) Target: x86_64-unknown-linux-gnu
swiftly list
Installed release toolchains ---------------------------- Swift 6.2.4 (in use) (default) Installed snapshot toolchains -----------------------------
You can remove the downloaded archive and extracted bootstrap binary once Swiftly is installed.
rm -f "swiftly-$(uname -m).tar.gz" swiftly
Install Swift from the official tarball on Ubuntu 24.04 or 22.04
The tarball method gives you the same upstream compiler without a version manager. This workflow stores each release in its own directory under /opt, points /opt/swift at the active version, and then exposes that path through a system-wide profile script.
Start by confirming your Ubuntu release and CPU architecture. Swift.org publishes separate tarballs for Ubuntu 24.04 and 22.04, plus separate archives for x86_64 and aarch64.
lsb_release -rs
uname -m
24.04 x86_64
Build the Swift download names next. Run the next few blocks in the same terminal session because they reuse these variables.
SWIFT_VERSION=$(curl -fsSL https://api.github.com/repos/swiftlang/swift/releases/latest | grep '"tag_name"' | head -n 1 | sed -E 's/.*"swift-([^"]+)-RELEASE".*/\1/')
UBUNTU_VERSION=$(lsb_release -rs)
ARCH=$(uname -m)
case "$UBUNTU_VERSION:$ARCH" in
24.04:x86_64) BASE_DIR=ubuntu2404; FILE_ARCH=""; FILE_VERSION=ubuntu24.04 ;;
24.04:aarch64) BASE_DIR=ubuntu2404-aarch64; FILE_ARCH=-aarch64; FILE_VERSION=ubuntu24.04 ;;
22.04:x86_64) BASE_DIR=ubuntu2204; FILE_ARCH=""; FILE_VERSION=ubuntu22.04 ;;
22.04:aarch64) BASE_DIR=ubuntu2204-aarch64; FILE_ARCH=-aarch64; FILE_VERSION=ubuntu22.04 ;;
*) echo "Use this tarball method on Ubuntu 24.04 or 22.04 only."; exit 1 ;;
esac
TARBALL="swift-${SWIFT_VERSION}-RELEASE-${FILE_VERSION}${FILE_ARCH}.tar.gz"
BASE_URL="https://download.swift.org/swift-${SWIFT_VERSION}-release/${BASE_DIR}/swift-${SWIFT_VERSION}-RELEASE"
Print the final download URL before you fetch anything. This gives you one last chance to confirm the release and architecture match your system.
echo "$BASE_URL/$TARBALL"
https://download.swift.org/swift-6.2.4-release/ubuntu2404/swift-6.2.4-RELEASE/swift-6.2.4-RELEASE-ubuntu24.04.tar.gz
Download the archive and its detached signature from Swift.org.
curl -fsSLO "$BASE_URL/$TARBALL"
curl -fsSLO "$BASE_URL/$TARBALL.sig"
Check that both files downloaded before you import the signing keys.
ls -lh "$TARBALL" "$TARBALL.sig"
-rw-rw-r-- 1 joshua joshua 962M Mar 13 12:39 swift-6.2.4-RELEASE-ubuntu24.04.tar.gz -rw-rw-r-- 1 joshua joshua 819B Mar 13 12:39 swift-6.2.4-RELEASE-ubuntu24.04.tar.gz.sig
The exact tarball size varies slightly by Ubuntu release and architecture, but you should see both files present before the signature step.
Import Swift’s public keys and verify the tarball before you extract it. The keys file is served compressed, so use curl --compressed for the import step.
curl --compressed -fsSL https://www.swift.org/keys/all-keys.asc | gpg --import
gpg --verify "$TARBALL.sig" "$TARBALL"
gpg: Signature made Thu 26 Feb 2026 07:33:54 PM AWST gpg: using RSA key EF80A866B47A981F gpg: Good signature from "Swift 6.x Release Signing Key <swift-infrastructure@forums.swift.org>" [unknown] gpg: WARNING: This key is not certified with a trusted signature!
A trust warning is normal here because the signing key is not in your personal web-of-trust. The important line is Good signature. Extract the archive into a versioned directory first, then point /opt/swift at that directory.
sudo rm -rf "/opt/swift-${SWIFT_VERSION}"
sudo mkdir -p "/opt/swift-${SWIFT_VERSION}"
sudo tar xzf "$TARBALL" -C "/opt/swift-${SWIFT_VERSION}" --strip-components=1
sudo ln -sfn "/opt/swift-${SWIFT_VERSION}" /opt/swift
Add Swift to your shell path next. The tee command writes the profile script as root because plain shell redirection would not inherit sudo.
printf '%s\n' 'export PATH=/opt/swift/usr/bin:$PATH' | sudo tee /etc/profile.d/swift.sh > /dev/null
. /etc/profile.d/swift.sh
Verify that the shell now resolves Swift from /opt/swift.
swift --version
Swift version 6.2.4 (swift-6.2.4-RELEASE) Target: x86_64-unknown-linux-gnu
readlink -f /opt/swift
/opt/swift-6.2.4
The Swift tarball is a standard .tar.gz archive. If you want a broader refresher on that format, see our guide on how to open .gz and .tgz files in Linux.
Remove the downloaded archive and signature after the install completes.
rm -f "$TARBALL" "$TARBALL.sig"
Create a Swift Project on Ubuntu
Swift Package Manager is the quickest way to confirm the compiler, package tools, and linker are all working together. It also depends on Git for dependency fetches, so install or upgrade Git on Ubuntu if your system does not have it yet.
Create a small executable package and run it.
mkdir ~/HelloSwift
cd ~/HelloSwift
swift package init --name HelloSwift --type executable
swift run HelloSwift
Building for debugging... [0/5] Write sources [1/5] Write swift-version--763D7A6E824AD11B.txt [3/7] Compiling HelloSwift HelloSwift.swift [4/7] Emitting module HelloSwift [7/8] Linking HelloSwift Build of product 'HelloSwift' complete! Hello, world!
The official Swift Package Manager getting started guide is the next place to go once you want dependencies, release builds, and a bigger project layout. If you prefer a GUI editor, install Visual Studio Code on Ubuntu and add the Swift extension from the marketplace.
Troubleshoot Swift on Ubuntu
Swiftly reports Unsupported Linux platform on Ubuntu 26.04
If you try Swiftly on Ubuntu 26.04 right now, the installer stops immediately with an unsupported platform error.
Error: Unsupported Linux platform
This happens because Swift.org has not published native Resolute toolchains yet. Use Ubuntu’s own package instead.
sudo apt install swiftlang
Verify that the compiler is available afterward.
swift --version
Swift version 6.1.3 (swift-6.1.3-RELEASE) Target: x86_64-pc-linux-gnu
Swift is not found after the tarball install
If the tarball extracted cleanly but the shell still cannot find swift, the profile script was not loaded in the current shell yet.
bash: line 1: swift: command not found
Load the system-wide profile script now so the tarball path is added to PATH immediately.
printf '%s\n' 'export PATH=/opt/swift/usr/bin:$PATH' | sudo tee /etc/profile.d/swift.sh > /dev/null
. /etc/profile.d/swift.sh
Confirm the shell now resolves the compiler from the tarball location.
swift --version
Swift version 6.2.4 (swift-6.2.4-RELEASE) Target: x86_64-unknown-linux-gnu
Update or Remove Swift on Ubuntu
Each installation path has its own maintenance workflow. Match the subsection below to the method you originally used: swiftlang on Ubuntu 26.04, Swiftly on Ubuntu 24.04 or 22.04, or the manual tarball on Ubuntu 24.04 or 22.04.
Update swiftlang on Ubuntu 26.04
Choose this subsection only if you installed Swift with Ubuntu’s swiftlang package on 26.04. Ubuntu handles updates through APT, so you only need the package upgrade command.
sudo apt install --only-upgrade swiftlang
Update Swiftly on Ubuntu 24.04 or 22.04
Choose this subsection only if you installed Swift with Swiftly. Swiftly updates the active toolchain and the manager itself with separate commands.
swiftly update
swiftly self-update
Swift 6.2.4 is already up to date Checking for swiftly updates... Already up to date.
Update the Swift tarball on Ubuntu 24.04 or 22.04
Choose this subsection only if you installed Swift manually under /opt. The tarball method does not include an in-place updater, so each update is a repeat of the download, signature check, extraction, and symlink steps from the install section.
After you refresh the tarball install, confirm which directory the symlink points to and which compiler version is active.
readlink -f /opt/swift
swift --version
/opt/swift-6.2.4 Swift version 6.2.4 (swift-6.2.4-RELEASE) Target: x86_64-unknown-linux-gnu
Once the new toolchain is active, remove the older versioned directory if you do not need a rollback copy anymore.
sudo rm -rf /opt/swift-OLD_VERSION
Remove Swift from Ubuntu 26.04
Use this removal path only for the Ubuntu 26.04 swiftlang package. Remove the package first, then let APT clean up the auto-installed Swift runtime library.
sudo apt remove swiftlang
sudo apt autoremove
Check the package state after removal.
apt-cache policy swiftlang
swiftlang:
Installed: (none)
Candidate: 6.1.3-4build1
Version table:
6.1.3-4build1 500
500 http://au.archive.ubuntu.com/ubuntu resolute/universe amd64 Packages
100 /var/lib/dpkg/status
Remove Swiftly from Ubuntu 24.04 or 22.04
Use this removal path only if you installed Swift with Swiftly. Remove all Swiftly-managed toolchains first. The --assume-yes flag skips the confirmation prompt.
swiftly uninstall all --assume-yes
Delete the manager directory and remove the profile lines Swiftly added to ~/.profile.
rm -rf ~/.local/share/swiftly
sed -i '/# Added by swiftly/d; /\.local\/share\/swiftly\/env\.sh/d' ~/.profile
Verify the Swiftly manager is gone.
command -v swiftly || echo swiftly-not-found
swiftly-not-found
Remove the Swift tarball from Ubuntu 24.04 or 22.04
Use this removal path only for the manual tarball install under /opt. Delete the symlink, the versioned toolchain directories, and the profile script if you no longer need that install.
The following commands permanently delete the tarball-based Swift install under
/opt. If you have multiple manual Swift versions there for testing, back up the ones you still need before you remove the whole/opt/swift-*set.
sudo rm -f /opt/swift
sudo rm -rf /opt/swift-*
sudo rm -f /etc/profile.d/swift.sh
hash -r
Confirm the tarball install is no longer on your shell path.
command -v swift || echo swift-not-found
swift-not-found
Swift on Ubuntu FAQ
No on Ubuntu 24.04 and 22.04. The swift package in those repositories belongs to OpenStack Swift object storage, not Apple’s programming language. Ubuntu 26.04 packages Apple’s language as swiftlang, so that is the package name to use there.
Not yet. Swiftly currently exits with Error: Unsupported Linux platform on Ubuntu 26.04 because Swift.org has not published native Resolute toolchains yet. Use swiftlang from Ubuntu 26.04 for now, and switch to Swift.org toolchains later if upstream adds native 26.04 support.
Swiftly still prints a legacy dependency hint for python3-lldb-13, but Ubuntu 24.04 no longer ships that exact package name. The compiler, Swift Package Manager, and CLI builds worked with curl, tar, git, gnupg2, libcurl4-openssl-dev, libpython3-dev, libxml2-dev, libz3-dev, pkg-config, and zlib1g-dev, so you do not need to chase that retired package name just to install the toolchain.
Use Swiftly if you want the simpler upstream workflow, home-directory installation, and built-in update command. Use the official tarball if you want a manager-free install under /opt and do not mind updating it yourself. Both methods installed Swift 6.2.4 successfully on Ubuntu 24.04 and 22.04.
Conclusion
Swift is installed on Ubuntu Linux with the method that fits your release, whether that is swiftlang on 26.04 or Swift.org’s upstream toolchains on 24.04 and 22.04. For editor integration, install Visual Studio Code on Ubuntu. Swift Package Manager also works best when Git is ready, so install or upgrade Git on Ubuntu if it is not already available.
Formatting tips for your comment
You can use basic HTML to format your comment. Useful tags currently allowed:
<code>command</code>command<strong>bold</strong><em>italic</em><blockquote>quote</blockquote>