Swift for the Raspberry Pi


Editor’s Note: Swift 3.0 for Raspberry Pi 2 and Pi 3 is now available! Head on over to our Swift 3.0 for Raspberry Pi post for instructions on how to download and install it.

The following is similar instructions to that provided for other ARM devices like BeagleBoneBlack and BeagleBoard X15. There are some slight differences to get clang-3.6 properly installed.

If you’ve already installed the swift-2.2 package with the instructions below and just want to upgrade to the latest version, use sudo apt-get update && sudo apt-get upgrade.

Disclaimer! Swift on ARM systems is very much at an alpha stage at the moment! The package below does not contain a working

12/27/15 Update: The REPL is now somewhat functional on BeagleBone and BeagleBoard, but there is a memory corruption error on the Raspberry Pi 2.
1/4/16 Update: Foundation is now working! Try some of the examples from this post.

You can track the progress of the port of Swift to ARM platforms at bugs.swift.org, and follow @iachievedit on Twitter for updates when new packages are released. To help out, create an account at bugs.swift.org and when you find broken stuff, file bugs and tag them with ‘arm’.


Both the clang-3.6 and libicu-dev packages need to be installed. In addition, you should use update-alternatives to provide /usr/bin links for clang and clang++. To get clang-3.6 on a Raspberry Pi 2 you can use repositories provided by Robert C. Nelson.

Run the following commands to add the rcn-ee repository:

wget http://repos.rcn-ee.com/debian/pool/main/r/rcn-ee-archive-keyring/rcn-ee-archive-keyring_2015.10.22~bpo90+20151022+1_all.deb
sudo dpkg -i rcn-ee-archive-keyring_2015.10.22~bpo90+20151022+1_all.deb
echo "deb [arch=armhf] http://repos.rcn-ee.com/debian/ jessie main" | sudo tee --append /etc/apt/sources.list
sudo apt-get update

Then, install the dependencies libicu-dev and clang-3.6:

sudo apt-get install libicu-dev
sudo apt-get install clang-3.6
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-3.6 100
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.6 100

Note: You must use update-alternatives to link /usr/bin/clang and clang++.


At the moment there are only Raspberry Pi 2 packages for Debian Jessie. I have tested the basic installation on a Raspberry Pi 2.

1. Add the repository key

wget -qO- http://dev.iachieved.it/iachievedit.gpg.key | sudo apt-key add -

2. Add the repository to sources.list

echo "deb [arch=armhf] http://iachievedit-repos.s3.amazonaws.com/ jessie main" | sudo tee --append /etc/apt/sources.list

3. Run apt-get update

sudo apt-get update

4. Install swift-2.2!

sudo apt-get install swift-2.2

Trying it Out

Again, a warning! There is no Swift package manager in this build yet and don’t expect to be able to use swift to run it in REPL mode. You can however compile basic applications, even those using Glibc and Foundation.

root@beaglebone:~# more helloWorld.swift 
print("Hello, world!")

for i in 1...10 {
root@beaglebone:~# swiftc helloWorld.swift 
root@beaglebone:~# ./helloWorld 
Hello, world!

or, try out swiftcat.swift which uses Glibc.

With the latest 0ubuntu11 release, Foundation is supported too!


  1. DaveReply

    Getting this on BBB. Is there a way it can be fixed?
    After this operation, 0 B of additional disk space will be used.

    # apt-get install swift-2.2
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    The following NEW packages will be installed:
    0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
    Need to get 63.0 MB of archives.
    After this operation, 0 B of additional disk space will be used.

    • Joe Post authorReply

      The 0 B of additional disk space will be used is now fixed:

      pi@raspberrypi:~ $ sudo apt-get install swift-2.2
      Reading package lists... Done
      Building dependency tree       
      Reading state information... Done
      The following packages will be upgraded:
      1 upgraded, 0 newly installed, 0 to remove and 53 not upgraded.
      Need to get 63.1 MB of archives.
      After this operation, 312 MB of additional disk space will be used.
  2. Paul LynchReply

    “var pp” would be better as “let pp”. Trivial, but it’s swift.

    • Joe Post authorReply

      Indeed. Interesting that the compiler didn’t catch that one, it usually emits a suggestion.

    • Joe Post authorReply

      I’ve been in touch with the folks that are doing the hard work of getting Swift and all of the other complementary components built. The REPL (powered by lldb) and PackageManager (a separate project) have been the lower priority items. A few builds have been done but there were issues with SwiftPM working completely. I would say we are still a month or more away from having a fully-built suite for ARM-based systems at this time. But definitely watch the @iachievedit Twitter feed, when it is available it will be broadcasted there.

    • Joe Post authorReply

      Carl, I don’t have a Pi 3 myself, but I may know some that do. I’ll ask and get back to you.

        • NelusReply

          I have a pi 3 and it works as well. Just follow the instructions above. I’m only wondering if Swift 3.0 is also available for the pi?

  3. NielsReply

    Hi, thanks for your great effort in the Swift open source world. I have a Raspberry Pi 3 with Swift 2.2 installed via one of your tutorials, working great except that the swift-build binary is not included. Is there a way to solve this? I’ve read things about the Release/Development branch from Swift, the Development branch should have swift-build included.

  4. Christian RishøjReply

    This might be a long shot, but what could be a viable route to getting a GUI up on the Raspberry Pi Touch Display using Swift?

Leave a Reply

Your email address will not be published. Required fields are marked *