How to Install Swift on Debian (13, 12, 11)

Last updated Sunday, March 1, 2026 2:59 pm 14 min read

Swift brings Apple’s compiled, type-safe language to Linux. Built-in concurrency, a package manager, and a growing server-side ecosystem make it a strong fit for backend services and command-line tools. Debian 13 (Trixie) is the first Debian release to package Swift in its default repositories, and Debian 12 (Bookworm) users can install Swift on Debian through Swiftly, Apple’s official toolchain manager, or by extracting the official pre-built tarball directly from swift.org.

After setup, you get the full Swift compiler, Swift Package Manager, and LLDB debugger. Swiftly handles version switching and toolchain updates independently of APT, the tarball provides a self-contained install with no external tool overhead, and Debian 13’s package follows the standard system upgrade workflow.

Install Swift on Debian Linux

Debian 13 provides Swift through its standard repositories. Debian 12 users can choose between Swiftly and a manual tarball, and the tarball also works on Debian 13 when you want the latest upstream release.

MethodChannelVersionUpdatesBest For
APTDebian Repos6.0.xapt upgradeDebian 13 – stable, system-managed
Swiftlyswift.org6.2.xswiftly updateDebian 12 – latest releases, multi-version switching
Tarballswift.org6.2.xManual downloadDebian 12/13 – standalone, no extra tooling

Swiftly currently supports Debian 12 only. Debian 11 (Bullseye) and Debian 13 (Trixie) are not yet recognized as supported platforms. The tarball method works on Debian 12 and 13 but requires glibc 2.34 or later, which excludes Debian 11.

Update Debian Before Installing Swift

Refresh the package index and apply any pending upgrades to avoid dependency conflicts during installation.

sudo apt update && sudo apt upgrade

This guide uses sudo for commands that need root privileges. If your user is not in the sudoers file yet, follow the guide on how to add a user to sudoers on Debian.

Install Swift via APT on Debian 13

Debian 13 (Trixie) includes the swiftlang package, which bundles the Swift compiler, package manager, LLDB debugger, and SourceKit-LSP.

sudo apt install swiftlang

Verify the installed version.

swift --version
Swift version 6.0.3 (swift-6.0.3-RELEASE)
Target: x86_64-pc-linux-gnu

Install Swift via Swiftly on Debian 12

Swiftly is Apple’s official toolchain manager for Swift on Linux. It downloads pre-built toolchains directly from swift.org – no APT repository, GPG key, or sources file is added to your system. Swiftly also manages version switching and updates for both Swift and itself.

Install the development libraries and tools the Swift toolchain requires, including a C compiler and header packages for core system libraries.

sudo apt install binutils gcc git pkg-config uuid-dev libcurl4-openssl-dev libedit-dev libicu-dev libncurses-dev libpython3-dev libsqlite3-dev libstdc++-12-dev libxml2-dev

Download and extract the Swiftly binary. The $(uname -m) variable automatically selects the correct archive for your CPU architecture (x86_64 or aarch64).

curl -O "https://download.swift.org/swiftly/linux/swiftly-1.1.1-$(uname -m).tar.gz"
tar -zxf "swiftly-1.1.1-$(uname -m).tar.gz"

Run the Swiftly installer, which places the swiftly binary in ~/.local/share/swiftly/bin/, configures your shell environment, and downloads the latest stable Swift toolchain.

./swiftly init

The swiftly init command downloads the latest stable Swift toolchain, which is approximately 960 MB. The download and extraction may take several minutes depending on your connection speed.

Swiftly adds a sourcing line to ~/.profile that loads automatically on future logins. Apply the changes to your current session by sourcing the environment file and resetting the shell’s command cache.

. "${SWIFTLY_HOME_DIR:-$HOME/.local/share/swiftly}/env.sh"
hash -r

Verify the installed Swift version.

swift --version
Swift version 6.2.4 (swift-6.2.4-RELEASE)
Target: x86_64-unknown-linux-gnu

You can also clean up the downloaded archive and extracted binary from your home directory now that Swiftly is installed.

rm -f ~/swiftly ~/swiftly-1.1.1-*.tar.gz

Install Swift via Tarball on Debian 12 or 13

Apple publishes pre-built Swift tarballs for Debian 12 on swift.org. The Debian 12 tarball also runs on Debian 13 since Trixie ships glibc 2.40, well above the 2.34 minimum. This method stores each version in its own directory under /opt and uses a symlink so your PATH never needs to change when you upgrade or switch versions.

Install the runtime libraries and development headers that the Swift toolchain depends on.

sudo apt install binutils git gnupg2 libc6-dev libcurl4-openssl-dev libedit2 libpython3-dev libsqlite3-0 libstdc++-12-dev libxml2-dev libz3-dev pkg-config tzdata unzip zlib1g-dev

Debian 13 ships libstdc++-14-dev instead of libstdc++-12-dev. Replace the package name in the command above if you are on Debian 13.

The official Swift tarball requires glibc 2.34 or later. Debian 11 (Bullseye) ships glibc 2.31 and cannot run the pre-built binaries. Upgrade to Debian 12 or 13 before using this method.

Query the GitHub releases API to find the latest stable version and store it in a shell variable. The grep -oP extracts just the version number from the JSON response so every subsequent command uses it automatically.

SWIFT_VERSION=$(curl -fsSL https://api.github.com/repos/swiftlang/swift/releases/latest \
  | grep -oP '"tag_name": "swift-\K[0-9]+\.[0-9]+(\.[0-9]+)?(?=-RELEASE)')
echo "Latest Swift version: $SWIFT_VERSION"

Download the tarball and its PGP signature using the detected version.

curl -fsSLO "https://download.swift.org/swift-${SWIFT_VERSION}-release/debian12/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-debian12.tar.gz"
curl -fsSLO "https://download.swift.org/swift-${SWIFT_VERSION}-release/debian12/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-debian12.tar.gz.sig"

Import Swift’s PGP signing keys and verify the download. The signature check confirms the tarball has not been tampered with in transit.

curl -fsSL https://swift.org/keys/all-keys.asc | gpg --import -
gpg --verify "swift-${SWIFT_VERSION}-RELEASE-debian12.tar.gz.sig" "swift-${SWIFT_VERSION}-RELEASE-debian12.tar.gz"

Look for Good signature from "Swift Automatic Signing Key" in the output. A trust warning about the key not being certified is normal and does not indicate a problem.

Extract the tarball into a versioned directory under /opt. The --strip-components=1 flag removes the top-level directory from the archive so the contents land directly inside the target path.

sudo mkdir -p "/opt/swift-${SWIFT_VERSION}"
sudo tar xzf "swift-${SWIFT_VERSION}-RELEASE-debian12.tar.gz" -C "/opt/swift-${SWIFT_VERSION}" --strip-components=1

Create a symlink at /opt/swift that points to the versioned directory. Your PATH references this symlink, so switching versions later only requires repointing the link.

sudo ln -sfn "/opt/swift-${SWIFT_VERSION}" /opt/swift

Add Swift to PATH on Debian

Debian’s default ~/.profile runs on login and sources ~/.bashrc, so a single PATH entry in ~/.profile covers interactive bash sessions. Pick the option that matches your shell and your needs.

Option A – Single-user, Bash (default Debian shell): add the PATH export to ~/.profile. This runs at login and covers both terminal sessions and graphical login environments.

echo 'export PATH=/opt/swift/usr/bin:"$PATH"' >> ~/.profile
source ~/.profile

Option B – Single-user, Zsh: if you have switched your default shell to Zsh, add the export to ~/.zshrc instead.

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

Option C – System-wide, all users: create a drop-in script in /etc/profile.d/. Every login shell on the system will pick this up automatically.

echo 'export PATH=/opt/swift/usr/bin:"$PATH"' | sudo tee /etc/profile.d/swift.sh
sudo chmod +x /etc/profile.d/swift.sh
source /etc/profile.d/swift.sh

The tee command writes to a root-owned file because normal redirection (>) does not inherit sudo privileges. The source command loads the new PATH into your current session so you do not need to log out.

Verify the installed version.

swift --version
Swift version 6.2.4 (swift-6.2.4-RELEASE)
Target: x86_64-unknown-linux-gnu

Confirm the shell is resolving the binary from the correct path.

which swift
/opt/swift/usr/bin/swift

Clean up the downloaded archive and signature file.

rm -f "swift-${SWIFT_VERSION}-RELEASE-debian12.tar.gz" "swift-${SWIFT_VERSION}-RELEASE-debian12.tar.gz.sig"

Install Additional Swift Tarball Versions on Debian

Because each version lives in its own /opt/swift-<version> directory, you can keep multiple releases side by side. Download and extract the second version into a new directory.

curl -fsSLO "https://download.swift.org/swift-5.10.1-release/debian12/swift-5.10.1-RELEASE/swift-5.10.1-RELEASE-debian12.tar.gz"
sudo mkdir -p /opt/swift-5.10.1
sudo tar xzf swift-5.10.1-RELEASE-debian12.tar.gz -C /opt/swift-5.10.1 --strip-components=1

Switch to the alternative version by repointing the symlink.

sudo ln -sfn /opt/swift-5.10.1 /opt/swift
swift --version
Swift version 5.10.1 (swift-5.10.1-RELEASE)
Target: x86_64-unknown-linux-gnu

Switch back to your primary version the same way.

sudo ln -sfn /opt/swift-6.2.4 /opt/swift
swift --version

List all installed tarball versions at any time.

ls -d /opt/swift-* 2>/dev/null

Check which version the symlink currently points to.

readlink -f /opt/swift
/opt/swift-6.2.4

Create a Swift Project on Debian

Swift Package Manager handles project scaffolding and dependency resolution, and it requires Git. Swiftly and tarball installations already include Git in the dependency set. Debian 13 APT users who do not have Git can install Git on Debian separately with sudo apt install git.

Create a directory for a new command-line tool and initialize the project.

mkdir ~/HelloSwift && cd ~/HelloSwift
swift package init --name HelloSwift --type executable

Build and run the project.

swift run HelloSwift
Building for debugging...
Build of product 'HelloSwift' complete!
Hello, world!

The Swift getting started guide covers adding dependencies, structuring larger projects, and building release binaries.

Manage Swift Installations on Debian

APT and Swiftly handle updates with built-in commands. The tarball section below includes a script that checks the GitHub releases API for new versions and automates the download, verification, and symlink rotation.

Update Swift via APT on Debian 13

Debian 13 users receive Swift updates through the standard package manager alongside other system packages.

sudo apt update && sudo apt install --only-upgrade swiftlang

Update Swift Toolchains with Swiftly on Debian

Swiftly handles Swift toolchain updates independently of APT. Update the active toolchain to the latest patch release for its major version.

swiftly update

To jump to the latest stable release across all major versions, specify latest.

swiftly update latest

Install Additional Swift Versions on Debian

Swiftly supports multiple toolchains side by side, which is useful for testing code against different Swift releases.

swiftly install 5.10

Switch the active version.

swiftly use 5.10

List all installed toolchains to see which one is active.

swiftly list

Update Swiftly on Debian

Swiftly checks for new releases of itself separately from Swift toolchains.

swiftly self-update

Update Swift Tarball Installation on Debian

Tarball installations do not include an automatic update mechanism, so you need to download the new release yourself. The script below automates the process: it queries the Swift GitHub releases for the latest stable version, compares it against the tarball you have installed at /opt/swift, downloads and verifies the new tarball if an update is available, extracts it to a versioned directory, and repoints the symlink. Run it manually whenever you want to check for updates.

Create the script file.

cat << 'SCRIPT' > ~/update-swift.sh
#!/bin/bash
# Update script for Swift tarball installations on Debian.
# Queries the GitHub releases API for the latest stable version,
# verifies the PGP signature, extracts into /opt/swift-<version>,
# and repoints the /opt/swift symlink. Run manually - do not
# automate with cron.
set -e

INSTALL_BASE="/opt"
SWIFT_LINK="${INSTALL_BASE}/swift"
SWIFT_BIN="${SWIFT_LINK}/usr/bin/swift"

## ── Preflight checks ──────────────────────────────────────────────
# The script must not run as root. Sudo is called only for file
# operations that need it, so the rest runs with normal permissions.
if [ "$(id -u)" -eq 0 ]; then
  echo "Error: run this script as a regular user, not root."
  exit 1
fi

# Verify that curl, gpg, and tar are available before starting.
for cmd in curl gpg tar; do
  if ! command -v "$cmd" >/dev/null 2>&1; then
    echo "Error: $cmd is required but not installed."
    exit 1
  fi
done

# Confirm that a tarball installation exists at /opt/swift.
if [ ! -L "$SWIFT_LINK" ] || [ ! -x "$SWIFT_BIN" ]; then
  echo "Error: no tarball installation found at $SWIFT_LINK."
  echo "This script manages Swift installed via tarball to /opt/swift-VERSION."
  exit 1
fi

## ── Version detection ──────────────────────────────────────────────
# Query the GitHub releases API for the latest stable tag. The
# endpoint returns the most recent non-prerelease, which follows
# the pattern swift-X.Y.Z-RELEASE.
echo "Checking GitHub for the latest stable Swift release..."
TAG=$(curl -fsSL "https://api.github.com/repos/swiftlang/swift/releases/latest" \
  | grep -oP '"tag_name": "\Kswift-[0-9]+\.[0-9]+(\.[0-9]+)?-RELEASE')

if [ -z "$TAG" ]; then
  echo "Error: could not detect the latest Swift version."
  exit 1
fi
LATEST_VERSION=$(echo "$TAG" | grep -oP '[0-9]+\.[0-9]+(\.[0-9]+)?')

# Read the currently installed version from the tarball binary at
# /opt/swift/usr/bin/swift rather than relying on PATH.
CURRENT_VERSION=$("$SWIFT_BIN" --version 2>/dev/null \
  | grep -oP 'Swift version \K[0-9]+\.[0-9]+(\.[0-9]+)?' \
  | head -n 1)

echo "Installed: Swift $CURRENT_VERSION ($(readlink -f "$SWIFT_LINK"))"
echo "Latest:    Swift $LATEST_VERSION"

if [ "$CURRENT_VERSION" = "$LATEST_VERSION" ]; then
  echo "Already up to date."
  exit 0
fi

## ── Download and verify ────────────────────────────────────────────
TARBALL="swift-${LATEST_VERSION}-RELEASE-debian12.tar.gz"
BASE_URL="https://download.swift.org/swift-${LATEST_VERSION}-release/debian12/swift-${LATEST_VERSION}-RELEASE"

echo ""
echo "Downloading Swift $LATEST_VERSION..."
curl -fSLO --progress-bar "${BASE_URL}/${TARBALL}"
curl -fsSLO "${BASE_URL}/${TARBALL}.sig"

echo "Importing Swift PGP keys and verifying signature..."
curl -fsSL https://swift.org/keys/all-keys.asc | gpg --import - 2>/dev/null
if ! gpg --verify "${TARBALL}.sig" "$TARBALL" 2>&1 | grep -q "Good signature"; then
  echo "Error: PGP signature verification failed. The download may be corrupted."
  rm -f "$TARBALL" "${TARBALL}.sig"
  exit 1
fi
echo "Signature verified."

## ── Extract and link ───────────────────────────────────────────────
INSTALL_DIR="${INSTALL_BASE}/swift-${LATEST_VERSION}"

echo "Extracting to $INSTALL_DIR..."
sudo mkdir -p "$INSTALL_DIR"
sudo tar xzf "$TARBALL" -C "$INSTALL_DIR" --strip-components=1

# Repoint the /opt/swift symlink so the PATH picks up the new
# version without editing any profile files.
echo "Updating symlink $SWIFT_LINK -> $INSTALL_DIR"
sudo ln -sfn "$INSTALL_DIR" "$SWIFT_LINK"

## ── Cleanup and verify ─────────────────────────────────────────────
rm -f "$TARBALL" "${TARBALL}.sig"

VERIFY=$("$SWIFT_BIN" --version 2>/dev/null \
  | grep -oP 'Swift version \K[0-9]+\.[0-9]+(\.[0-9]+)?' \
  | head -n 1)
echo ""
echo "Swift updated from $CURRENT_VERSION to $VERIFY"
echo "The previous directory /opt/swift-${CURRENT_VERSION} is still on disk."
echo "Remove it with:  sudo rm -rf /opt/swift-${CURRENT_VERSION}"
SCRIPT
chmod +x ~/update-swift.sh

The script performs these steps in order:

  • Confirms it is not running as root, that curl, gpg, and tar are available, and that a tarball installation exists at /opt/swift.
  • Queries the Swift GitHub releases API for the latest stable tag and extracts the version number.
  • Reads the installed version from /opt/swift/usr/bin/swift directly instead of relying on your shell PATH.
  • Exits early if the installed and latest versions match.
  • Downloads the tarball and its .sig file, imports Swift’s PGP keys, and verifies the signature.
  • Extracts the new release into /opt/swift-<version> and repoints the /opt/swift symlink.
  • Cleans up the downloaded files and prints the new version. The previous version directory is kept so you can roll back by repointing the symlink.

Run the script to check for and apply updates.

~/update-swift.sh

When an update is available, the output looks like this.

Checking GitHub for the latest stable Swift release...
Installed: Swift 6.2.4 (/opt/swift-6.2.4)
Latest:    Swift 6.3.0

Downloading Swift 6.3.0...
###################################### 100.0%
Importing Swift PGP keys and verifying signature...
Signature verified.
Extracting to /opt/swift-6.3.0...
Updating symlink /opt/swift -> /opt/swift-6.3.0

Swift updated from 6.2.4 to 6.3.0
The previous directory /opt/swift-6.2.4 is still on disk.
Remove it with:  sudo rm -rf /opt/swift-6.2.4

When you are already on the latest version.

Checking GitHub for the latest stable Swift release...
Installed: Swift 6.2.4 (/opt/swift-6.2.4)
Latest:    Swift 6.2.4
Already up to date.

Avoid automating this script with cron. The download is nearly 1 GB and PGP verification can fail if keys rotate. Run it manually so you can monitor the output and catch any problems before they affect your projects.

Remove Swift from Debian Linux

Remove Swift APT Package from Debian

Debian 13 users can remove the APT package and clean up unused dependencies.

sudo apt remove swiftlang
sudo apt autoremove

Verify the package is removed.

apt-cache policy swiftlang
swiftlang:
  Installed: (none)
  Candidate: 6.0.3-2
  Version table:
     6.0.3-2 500
        500 http://deb.debian.org/debian trixie/main amd64 Packages

Remove Swiftly and Swift Toolchains from Debian

Remove all installed Swift toolchains first.

swiftly uninstall all

Delete the Swiftly directory, which contains the binary, configuration, and any remaining toolchain data.

rm -rf ~/.local/share/swiftly

Remove the Swiftly sourcing lines from your shell profile.

sed -i '/# Added by swiftly/d; /\.local\/share\/swiftly\/env\.sh/d' ~/.profile

Clean up the original download files if they are still in your home directory.

rm -f ~/swiftly ~/swiftly-1.1.1-*.tar.gz

Log out and back in, or source your profile to apply the changes.

source ~/.profile

Remove Swift Tarball Installation from Debian

Delete the symlink, all versioned toolchain directories, and the update script.

sudo rm -f /opt/swift
sudo rm -rf /opt/swift-*
rm -f ~/update-swift.sh

Remove the PATH entry from whichever profile file you used during installation.

sed -i '/\/opt\/swift\/usr\/bin/d' ~/.profile ~/.bashrc ~/.zshrc 2>/dev/null
sudo rm -f /etc/profile.d/swift.sh

Apply the change in your current session.

hash -r
source ~/.profile

Confirm Swift is no longer found.

swift --version
-bash: swift: command not found

Frequently Asked Questions

Does Swiftly add an APT repository to Debian?

No. Swiftly downloads pre-built toolchains directly from swift.org and stores them in ~/.local/share/swiftly/toolchains/. No repository, GPG key, or sources file is added to the system. Updates happen through swiftly update, not apt.

Why does Swiftly show “Unsupported Linux platform” on Debian 13?

Swiftly 1.1.1 has not added Debian 13 (Trixie) to its list of recognized platforms yet. Debian 13 users can install Swift through the swiftlang APT package instead, which provides Swift 6.0.x from the default repositories.

Can I install Swift on Debian 11?

No. The swiftlang APT package is only in Debian 13, Swiftly recognizes only Debian 12, and the official tarball requires glibc 2.34 or later (Debian 11 ships glibc 2.31). Upgrading to Debian 12 or 13 is needed for Swift development.

Can I run multiple Swift versions on Debian with Swiftly?

Yes. Swiftly supports installing multiple toolchains side by side. Use swiftly install to add a version and swiftly use to switch between them. The swiftly list command shows all installed toolchains and which one is active. The APT package on Debian 13 supports only one version at a time.

Conclusion

Swift is configured on your Debian system with the compiler, package manager, and debugger ready for use. Debian 13’s APT package stays pinned to a tested release, Swiftly on Debian 12 handles version switching and automatic updates, and the tarball provides a lightweight standalone install on either release. For editor integration with the Swift extension, install Visual Studio Code on Debian. Swift Package Manager depends on Git for dependency resolution, so install Git on Debian if it is not already present. Developers working with multiple compiled languages can also install Rust on Debian.

Search LinuxCapable

Need another guide?

Search LinuxCapable for package installs, commands, troubleshooting, and follow-up guides related to what you just read.

Found this guide useful?

Support LinuxCapable to keep tutorials free and up to date.

Buy me a coffee Buy me a coffee

Before commenting, please review our Comments Policy.
Formatting tips for your comment

You can use basic HTML to format your comment. Useful tags currently allowed:

You type Result
<code>command</code> command
<strong>bold</strong> bold
<em>italic</em> italic
<blockquote>quote</blockquote> quote block

Leave a Comment

We read and reply to every comment - let us know how we can help or improve this guide.

Let us know you are human: