Swift on a Raspberry Pi (in 2024)

Five years ago installing Swift on a Raspberry Pi – or really any non-Apple platform – was fairly involved. Compared to getting a Raspberry Pi working to begin with it was easy, but still a far cry from apt install swift.

Sadly it’s still not quite that easy (and some Python package is squatting on the swift package name ๐Ÿคจ).

You can still install from source, in principle, although I’m not aware of any current instructions on how to do so. The buildSwiftOnARM project has seemingly been abandoned. I haven’t tested if their now-years-old instructions still work for the latest versions of Swift (e.g. 5.10, 6.0).

But, you shouldn’t need to build from source anymore – now you have many better options:

Swift.org (Apple-provided options)

  • If you happen to be using a yum-centric platform, like RHEL / Amazon Linux / CentOS, you can (finally!) just install RPMs.
  • If you happen to use one of the officially supported Linux distributions, you can install via Docker. Alas many major distros are notably absent from that list, like Debian1 (and therefore Raspbian). ๐Ÿ˜”

    It’s unfortunate that Swift.org pushes this as the preferred way to install Swift on Linux. I avoid Docker because it tends to just make everything more complex (and error-prone), and encourage bad software practices (“it works in my docker image ๐Ÿ–•”).
    • You can bypass the Docker requirement via the relatively primitive method of splatting a tarball into your system. It works, it’s pretty quick, but it’s a maintenance hassle (no version management, no reliable update method, etc).

Swift Community Apt Repository

Thanks to the efforts of community volunteers – in particular the folks at FutureJones – there is the Swift Community Apt Repository, which fills the massive void left by Apple’s apparent hatred for apt-based distros:

  1. curl -s https://archive.swiftlang.xyz/install.sh | sudo bash
  2. sudo apt install swiftlang
  3. There is no step 3!

More details (including the list of supported distros).

It’s a shame that it falls to third parties to make Swift on Linux easy (on major distros, at least). Don’t forget to support them if you benefit from their work!

โ˜๏ธ FutureJones also run Swift-Arm, which implies that only Swift 5.8 (and older) are supported. But in fact 5.10 is available – it seems they’ve just forgotten / chosen to stop posting about newly supported Swift versions.

  1. Though it appears Debian support is in the works. โ†ฉ๏ธŽ

2 thoughts on “Swift on a Raspberry Pi (in 2024)”

  1. I’m using Swift on a RPi5/CM4 for the control plane and UI of an embedded audio product. It’s working well!

    Reply

Leave a Comment