Set up Swift environment on Raspberry Pi (part 2/2)

I give a big thanks to the man sitting behind He made a tremendous effort to make the Swift setup easier than ever.

Hello guys, In this post, I will talk through on installing Swift environment for programming on Raspberry Pi. The Swift version will be set up is Swift 4.1.1

This tutorial is done on Raspberry Pi Model 3 B+ with Raspbian Stretch Lite. If you haven’t set up the Raspbian OS, learn more here

Ok, No more word, let’s started.

Set it up

First and foremost, plug the cord and remotely connect to the Raspberry from your computer over ssh in the terminal. Just simply use the following command

ssh pi@raspberry_ip_here

(The default user is pi, password is raspberry)

Second, We need to update apt-get, use this command

sudo apt-get update
sudo apt-get upgrade

Third, We need some software in place

sudo apt-get install git
sudo apt-get install nano

Ok, Now We’re good to set up Swift. This will be done by the help from author of

curl -s | sudo bash
sudo apt-get install swift-4.1-RPi23-RaspbianStretch

Ok, you’re done. Now, let’s double check again. Use this following command to check the Swift version set up on Raspberry Pi.

swift -version

check swift version on terminal

When you get the above message, then congratulation!. Swift is ready.

Make Hello world!

Ok, let’s make a simple program to say hello.

Create a swift file to print out “hello world”

echo 'print("hello world!")' > hello.swift

Finally, run it

swift hello.swift


hello world in swift

To continue editing the program and do something exciting, you can open the file hello.swift by nano, vim or whatever. My favorite is nano.

nano hello.swift

nano hello.swift.png

What’s next

Do you feel excited? Let’s write any simple program in swift and share your experience. If you have any trouble, please feel free to ask here.

Next, I’ll share you guys the most convienience and profressional way to work on a Swift project.

You’ll be able to code Swift with XCode on MAC OS or Visual Studio Code, so stay tune.

Reference resources:

2 thoughts on “Set up Swift environment on Raspberry Pi (part 2/2)

  1. Hello Hai! First of all, thanks for all your work to make Swift easier to use on Raspberry. I am having some problems installing Swift following the steps of the Swift-Arm website, my Raspbian OS can’t find the swift-4.1-RPi23-RaspbianStretch (or others) using apt-get, but I can find the Swift 5. The curl command returns the following errors: bash: linha 1: erro de sintaxe próximo ao token inesperado `newline’
    bash: linha 1: `’

    So, using another page, curl -s | sudo bash (, it works. And now Swift 5 appears, but today I’m studying if I can use it. If you have any ideas, I will appreciate your words.

    I`m new on Swift and Raspberry, sorry if I’m writing dumb things. And sorry for my English, I’m from Brazil, a lot of time without using it, a lot of rust. 🙂

    Thanks again! Best regards.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s