How to Install Swift on Arch Linux

Install Swift on Arch Linux using AUR packages. Includes swiftly toolchain manager, VS Code setup, and troubleshooting tips.

Last updatedAuthorJoshua JamesRead time7 minGuide typeArch Linux

Arch does not ship Swift in the official repositories, so the practical way to install Swift on Arch Linux is through the AUR: either the packaged binary toolchain or Swift’s official Swiftly manager. Both routes use upstream Linux toolchains rather than a native Arch repository build, which makes package source, PATH ownership, and update behavior worth checking before you start.

The current AUR binary package tracks Swift 6.3.x from Swift.org, while Swiftly can install the latest stable release, older release families such as Swift 6.2 for project compatibility, or snapshot toolchains for testing. Use the system-wide package for one stable compiler, or Swiftly when a project needs multiple toolchains.

Install Swift on Arch Linux

Choose one Swift installation method unless you intentionally want to rebuild your setup later. The AUR metadata prevents normal co-installation between swift-bin and swiftly-bin because both represent Swift toolchain ownership in pacman.

Choose a Swift Installation Method on Arch Linux

MethodSourceToolchain ScopeUpdate BehaviorBest For
swift-binAUR binary packageCurrent stable Swift releaseAUR helper and pacman package updatesMost users who want one system-wide Swift compiler
swiftly-binAUR Swiftly bootstrap packageMultiple stable or snapshot toolchainsSwiftly manages user toolchains; AUR updates the bootstrap packageDevelopers testing projects against multiple Swift versions

swift-bin repackages the official Swift.org RHEL 9 toolchain for Arch and creates system paths such as /usr/bin/swift, /usr/bin/swiftc, and /usr/bin/sourcekit-lsp. swiftly-bin installs the Swiftly manager plus Arch compatibility links; after initialization, Swiftly downloads toolchains into your home directory and controls which one is active.

The AUR also contains a source-build package named swift-language, but that route is not a normal install path for most readers. It needs an existing Swift compiler for bootstrapping, can lag behind current releases, and takes substantially more time than using the binary package or Swiftly.

Update Arch Linux Before Installing Swift

Refresh package databases and apply pending Arch updates before building or installing AUR packages:

sudo pacman -Syu

These commands use sudo for tasks that need root privileges. If your user is not in the sudoers file yet, run the commands as root or follow the guide on how to add and manage sudo users on Arch Linux.

Prepare AUR Access for Swift Packages

Swift on Arch uses AUR packages, so install the standard build tools and Git if they are not already present:

sudo pacman -S --needed base-devel git

You also need an AUR helper such as yay on Arch Linux or paru on Arch Linux. AUR packages are community-maintained, so review the PKGBUILD before approving the build.

Install Swift with swift-bin from the AUR

The swift-bin package is the simplest path when you want one current Swift compiler available system-wide. Install it with your AUR helper:

yay -S swift-bin

Use the matching paru command if that is your helper:

paru -S swift-bin

Confirm the installed compiler and package ownership after installation:

swift --version
command -v swift
pacman -Qo "$(command -v swift)"

Current Swift.org and AUR metadata show Swift 6.3.1, and later package builds may show a newer patch release. Your output should show the active Swift release and the x86_64-unknown-linux-gnu target on typical amd64 Arch systems:

Swift version 6.3.1 (swift-6.3.1-RELEASE)
Target: x86_64-unknown-linux-gnu
/usr/bin/swift
/usr/bin/swift is owned by swift-bin 6.3.1-1

Install Swiftly with swiftly-bin from the AUR

Use swiftly-bin when you need multiple Swift releases, snapshot toolchains, or project-specific toolchain switching. Install the AUR package first:

yay -S swiftly-bin

With paru, use the same package name:

paru -S swiftly-bin

Initialize Swiftly non-interactively and select the UBI9 platform. Swiftly does not have a native Arch platform selector, and the AUR package is built around Swift’s RHEL 9 compatible Linux toolchains:

swiftly init --assume-yes --platform ubi9 --quiet-shell-followup

Load Swiftly’s shell environment in the current terminal session, then refresh the shell command cache:

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

Confirm Swiftly and the active Swift toolchain:

command -v swiftly
command -v swift
swift --version
swiftly list

Swiftly should list the stable toolchain it installed and mark it as the in-use or default release. If it prints RHEL or yum dependency suggestions during initialization, treat those as upstream UBI9 notes; the Arch-side runtime compatibility comes from the swiftly-bin package dependencies and symlinks.

Manage Swift Toolchains with Swiftly

Swiftly is useful when one project expects a different Swift toolchain than another. The selector syntax accepts full releases, release families, latest, and snapshot branches.

Install a Specific Swift Release

If a project requires Swift 6.2 in Package.swift or CI, install that release family instead of forcing the newest toolchain:

swiftly install 6.2

Install the latest stable release when you want Swiftly to resolve the current release automatically:

swiftly install latest

Switch Toolchains for a Project

Select a toolchain as the active default for the current context:

swiftly use 6.2

Run one command with a specific installed toolchain without changing your default:

swiftly run swift --version +6.2

For packages that use a .swift-version file, run Swift commands through swiftly run from the project directory so Swiftly can select the matching toolchain.

Install Snapshot Toolchains

Install the latest snapshot from Swift’s main development branch only when you need to test upcoming compiler or language behavior:

swiftly install main-snapshot

Run a command through that snapshot after installation:

swiftly run swift --version +main-snapshot

Check Available Swift Toolchains

List releases and snapshots that Swiftly can install:

swiftly list-available

Use the visible release family or full patch release from that list when you need to match a project requirement. Avoid pinning a random old patch unless the project or CI pipeline actually requires it.

Verify Swift Development on Arch Linux

Create a small executable package to confirm that the compiler and Swift Package Manager work together:

mkdir -p ~/swift-test
cd ~/swift-test
swift package init --name swift-test --type executable

The project directory should contain a package manifest and source tree:

Creating executable package: swift-test
Creating Package.swift
Creating .gitignore
Creating Sources/
Creating Sources/main.swift

Build and run the package:

swift run swift-test
Building for debugging...
Build complete!
Hello, world!

Remove the test project after verification:

cd ~
rm -rf ~/swift-test

Configure Swift Development Tools on Arch Linux

Use VS Code with SourceKit-LSP

If you already use Visual Studio Code, install the Swift extension from the Visual Studio Marketplace. Swift packages include SourceKit-LSP, so the extension can provide completion, diagnostics, and jump-to-definition once the active swift toolchain is on your PATH.

Confirm SourceKit-LSP is available from the same shell where VS Code or your editor launches Swift tooling:

command -v sourcekit-lsp

Use the Swift REPL

The Swift REPL depends on LLDB support and may need the optional python39 AUR package for libpython3.9.so.1.0. Normal swift build, swift run, and package development do not need this optional dependency.

swift repl
Welcome to Swift version 6.3.1 (swift-6.3.1-RELEASE).
Type :help for assistance.
  1> 1 + 1
$R0: Int = 2
  2> :quit

If the REPL reports a missing Python 3.9 shared library, install the optional AUR dependency only if you need interactive REPL or debugger workflows. Use paru -S python39 instead if paru is your AUR helper:

yay -S python39

Update or Remove Swift on Arch Linux

Update swift-bin

Update the system-wide Swift package through the same AUR helper that installed it:

yay -Syu swift-bin

With paru, use the matching package update command:

paru -Syu swift-bin

Update Swiftly and Swift Toolchains

Swiftly has two update layers. Keep the AUR bootstrap package current first:

yay -Syu swiftly-bin

Use the matching paru command if paru installed the package:

paru -Syu swiftly-bin

Then update the account-local Swiftly manager and installed stable toolchain:

swiftly self-update
swiftly update latest

swiftly self-update updates the Swiftly copy in your user bin directory, while swiftly update latest updates the installed Swift toolchain that Swiftly manages.

Remove swift-bin

Remove the system-wide Swift binary package with pacman:

sudo pacman -Rns swift-bin

Confirm the package is no longer installed:

pacman -Q swift-bin
error: package 'swift-bin' was not found

Remove Swiftly and Managed Toolchains

Remove all Swiftly-managed toolchains before removing the AUR bootstrap package:

swiftly uninstall all --assume-yes

Deleting Swiftly’s account-local directory removes manager state and installed toolchains. Skip this cleanup if you plan to reinstall Swiftly and want to keep your downloaded toolchains.

rm -rf "${SWIFTLY_HOME_DIR:-$HOME/.local/share/swiftly}" "$HOME/.local/bin/swiftly"

Remove the AUR package after the user-level toolchains are gone:

sudo pacman -Rns swiftly-bin

Confirm the bootstrap package is no longer installed:

pacman -Q swiftly-bin
error: package 'swiftly-bin' was not found

If Swiftly added a block to your shell profile, remove the lines marked # Added by swiftly from files such as ~/.bashrc, ~/.zshrc, or another profile file used by your shell.

Troubleshoot Swift on Arch Linux

Swift Command Not Found After Swiftly Init

If swiftly list works but swift is not found, the current shell has not loaded Swiftly’s environment file yet:

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

Open a new terminal after the profile change if the current session still uses an older PATH.

Swiftly Toolchain Verification Cannot Find GPG

Swiftly verifies downloaded toolchains by default. On minimal Arch systems, install the official gnupg package if swiftly install or swiftly update reports missing GPG support:

sudo pacman -S gnupg

Retry the Swiftly operation after gpg is available:

swiftly install latest

libncurses.so.6 Error After Raw Swiftly Install

If a raw upstream Swiftly tarball install fails with libncurses.so.6: cannot open shared object file on Arch, switch to the swiftly-bin AUR package. The AUR package installs compatibility symlinks for Swift’s UBI9 binaries, while the raw upstream tarball expects the RHEL-style library names.

libxml2 Library Error

If Swift reports a missing libxml2.so.2 library, reinstall the Arch compatibility package used by the AUR Swift packages:

sudo pacman -S libxml2-legacy

Then check Swift again:

swift --version

Swift REPL Missing Python 3.9

If swift repl fails with libpython3.9.so.1.0: cannot open shared object file, install the optional python39 AUR package and retry the REPL. Because python39 is a separate AUR package, review its PKGBUILD before installing it. Do not install it for normal Swift Package Manager builds unless the REPL or LLDB workflow is the part you need.

Package Conflict Between swift-bin and swiftly-bin

If pacman reports a conflict involving swift-language, first check which Swift provider is installed:

pacman -Q swift-bin swiftly-bin swift-language

Remove the installed provider before switching methods. For swift-bin, use:

sudo pacman -Rns swift-bin

For the older source-build package, use:

sudo pacman -Rns swift-language

For Swiftly, remove managed toolchains before moving to the system-wide binary package:

swiftly uninstall all --assume-yes
sudo pacman -Rns swiftly-bin

Official Linux Toolchain and Static SDK Questions

Swift.org documents Linux installation through Swiftly and official Linux toolchains, but it does not publish a native Arch pacman repository. If you need a fully statically linked Linux binary, use Swift’s Static Linux SDK documentation after you have a working Swift toolchain; that is a separate deployment workflow from installing the compiler on Arch.

Conclusion

You have a current Swift toolchain on Arch through either swift-bin for one system-wide compiler or Swiftly for multi-version project work. Keep the AUR package, Swiftly’s user-level toolchains, and project-specific version selectors separate, then continue with Git on Arch Linux or an AUR helper workflow such as yay on Arch Linux.

Share this guide

Help another Linux user troubleshoot faster

Share this guide with someone troubleshooting Linux systems or saving it for later.

Follow LinuxCapable

Want more LinuxCapable guides in Google?

Add LinuxCapable as a preferred source so Google can show more of our fresh Linux tutorials in Top Stories and From your sources when relevant.

Add LinuxCapable as a preferred source on Google
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 coffeeBuy 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 in published comments:

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

Got a Question or Feedback?

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

Verify before posting: