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

I give a big thanks to the man sitting behind swift-arm.com. 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 swift-arm.com

curl -s https://packagecloud.io/install/repositories/swift-arm/debian/script.deb.sh | 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:

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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