1

I am a longtime iOS OS X developer who's switched most of his work to Swift.

Now that Swift is open source, it has been offered for non-Apple ARM devices like the Pi.

Based on my reading, it looks like you need to install Ubuntu on your Pi in order to get the Swift compiler up and running, so that's what I've done.

I then downloaded the latest Swift package for Pi and installed it, following the instructions on this page: http://dev.iachieved.it/iachievedit/swift-3-0-on-raspberry-pi-2-and-3/

However, when I try to create an run a simple hello world Swift app with the command "swift hello.swift" I get an error I don't understand:

/home/build/workspace/Swift-3.0-Pi3-ARM-Incremental/swift/lib/Serialization/ModuleFile.cpp:1031: swift::serialization::Status swift::ModuleFile::associateWithFileContext(swift::FileUnilt *, swift::SourceLoc): Assertion `getStatus() == Status::Valid && "Invalid module file"' failed.

And:

Stack Dump:
0.    Program Arguments: /home/ubuntu/swift-3.0/usr/bin/swift -frontend -interpret hello.swift -target arm7--linux-gnueabihf -disable-objc-interop -color-diagnostics -module-name hello
1.    While reading from /home/ubuntu/swift-3.0/usr/lib/swift/linux/arm7/Swift.swiftmodule

Can anybody tell me what's going wrong? I'm not super-strong with the UNIX command line I'm afraid. Conversant, but not fluent.

scruss
  • 9,117
  • 1
  • 25
  • 36
Duncan C
  • 119
  • 2

2 Answers2

1

Swift does work out of the box on Ubuntu but only on Intel devices, so not on ARM. However, Uraimo has made some scripts to easily build the swift compiler on a raspberry with Raspbian. https://github.com/uraimo/buildSwiftOnARM#building-swift-on-arm

0

The Swift language can be installed onto a Raspberry Pi from the Swift Community Apt Repository with the following commands:

### Check if curl is installed
which -a curl
sudo apt install -y curl # if not already installed

Instal Swift package repository via script

curl -s https://archive.swiftlang.xyz/install.sh | sudo bash

Install Swift

sudo apt install swiftlang

Check Swift version

swift --version

#Swift version 5.10 (swift-5.10-RELEASE) #Target: aarch64-unknown-linux-gnu

Resources

marc-medley
  • 543
  • 2
  • 5
  • 16