A Big Update on Swift 4.1.2 For Raspberry Pi Zero/1/2/3

Posted by Umberto Raimondi on June 13, 2018

Update 12/2018: Swift 4.1.3 is now available! Get it for RaspberryPi 2/3 with Ubuntu 16.04, RaspberryPi 2/3 with Raspbian and RaspberryPi Zero or 1 with Raspbian. Various improvements to buildSwiftOnARM that does not require the manual Swig compilation step anymore.

And after a long hiatus, I have another update on the status of Swift on Raspberry Pi and other ARM boards, this time regarding the long awaited support for Swift 4.1 and the work that has been done in the last few months.

This time around we have to thank Marco Chini for getting the first build and identifying various workarounds needed to finally get a build with a working SPM.

As usual, the community built around the swift-arm Slack channel was responsible for ironing out a plethora of additional issues and testing on various SBCs.

And as if that wasn’t enough, thanks to Helge Heß (author of dockSwiftOnARM and lately of a few NIO projects like Redi/s, NIO-IRC, etc…), support for 32bit ARM has been added to the recently released SwiftNIO. This will come in handy now that every major Server-Side Swift project is moving to this new networking framework.

Current Status and Issues

While fixes and workarounds have been found for the few major issues that were identified, there are still a few open issues remaining on Foundation. Feel free to open new issues on buildSwiftOnARM if you spot additional problems and crashes.

At the moment Swift cannot be built on ARMv6 boards like the original Raspberry or the Zero. This could change soon, but for now, no Swift 4.x on the low-end Raspberry Pis.

Prebuilt binaries

If you are using a Raspberry Pi 2 or 3 with Ubuntu Mate 16.04, that has been for some time the distribution I recommend, you can download the binaries for the release 4.1.2 from here (install the dependencies with: sudo apt install clang-3.8 libicu-dev libcurl4-nss-dev), while binaries for Raspbian Stretch can be found here.

Just decompress the tgz archive and both swiftc and swift will be available under ./usr/bin. Use the former to compile Swift files directly or the swift binary to access additional tools like SPM (as usual the REPL will not be available).

If you have patience and a few hours to spare, check out the updated buildSwiftOnARM scripts to build your own 4.1.2 binaries.

And for those interested in IoT projects, SwiftyGPIO has been updated to 4.1 and has now finally reached the 1.0.x release.

Community-hosted Continuous Integration

Some of you will already know that thanks to hpux735 and the Community Hosted CI initiative the testing infrastructure used by Swift now includes an Linux/ARMv7 testing environment.

This could make supporting Linux/ARM a way less demanding endeavor and could lead to releases of Swift on ARM more in line with the official schedule.

Swift and AArch64

The last few months, Neil Jones has focused his efforts on Swift and Kitura on 64bit ARMs, check out his posts here and try his prebuilt binaries available here.

Building on Raspbian Stretch

The Swift project now requires a version of Swig greater that 3.0.12, newer than the one shipped with Stretch.

To compile the project you’ll need to update it manually as follows:


wget http://ftp.de.debian.org/debian/pool/main/s/swig/swig_3.0.12-1.2_armhf.deb
wget http://ftp.de.debian.org/debian/pool/main/s/swig/swig3.0_3.0.12-1.2_armhf.deb

sudo dpkg -i swig3.0_3.0.12-1.2_armhf.deb swig_3.0.12-1.2_armhf.deb

The additional patches we were used to apply to build Swift 3.1.1 on Raspbian are not required anymore with 4.1.

Did you like this article? Let me know on Twitter or subscribe for updates!

This is the blog of Umberto Raimondi, you can reach me at me@this domain.

I'm also on Twitter and GitHub.

Subscribe via RSS or email.