Swift-Arm
HomeNewsInstall SwiftAbout
Raspberry Pi
Swift Development on the Raspberry Pi4
FutureJones
FutureJones
January 18, 2021
1 min

swift print

Setting up a Swift Development Environment on the Raspberry Pi4/400

In this tutorial we will learn how to set up a development environment for Swift on the Raspberry Pi4/400.
We will be starting with a fresh install of Ubuntu 20.10 and then installing the latest version of Swift 5.3.3 as well as Visual Studio Code.
VSCode is now officially supported on Arm devices and has great support for Swift.

To take advantage of all the latest Swift has to offer, a 64bit OS (Operating System) is recommended.
For ease of installation and compatibility, Ubuntu 20.10 is recommended.

Step 1 - Installing Ubuntu 20.10 Groovy Gorilla

Download and installation instructions for Ubuntu 20.10 are available here - Download Ubuntu
Once you have installed and booted into Groovy Gorilla make sure you do a system update.
This can done via the Software Updater or using the Terminal.

sudo apt update && sudo apt upgrade

update os

Step 2 - Installing Swift

Swift is available on the Swift-Arm / release package repository and can be installed using the apt package manager.
First we need to add the repository by running the following command -

curl -s https://packagecloud.io/install/repositories/swift-arm/release/script.deb.sh | sudo bash

and the run the Swift install command -

sudo apt install swiftlang

To check the Swift version installed run the following command -

swift --version

Step 3 - Installing VSCode

VSCode is available on the Swift-Arm / vscode package repository and can be installed using the apt package manager.
First we need to add the repository by running the following command -

curl -s https://packagecloud.io/install/repositories/swift-arm/vscode/script.deb.sh | sudo bash

and the run the VSCode install command -

sudo apt install code

Once VSCode is installed you can launch the app from application menu screen. vscode installed

Step 4 - Adding VSCode Extensions

While VSCode has good support for Swift out of the box there are also some great extensions you may want to install.

1 - Code Runner

Code Runner makes it easy to quickly run and test your code. code runner

2 - Swift Language

The Swift Language extension adds support for Colorization, Snippets and Grammar swift extension

To install an extension simply tap the Install button.

Step 5 - Create and Run a Hello World Project

1 - Create a new file.

Create a new file and name it helloworld.swift

2 - Add some code.

Add a simple print statement to print “Hello World!”

print("Hello World!")

helloworld

3 - Run the code.

Tap the run button to execute the code.

run helloworld

Congratulations! You now have a working Swift development environment on your Raspberry Pi.

Whats Next?

  • Learn Swift from the official documentation - Swift.org
  • Explore Server Side Swift - Kitura.

Hope you enjoy coding with Swift on your Raspberry Pi!


Tags

swiftraspberry piubuntututorial
FutureJones

FutureJones

Software Engineer / Project Management

Founder, Engineer, Architect, Manager. Supporting open source software.

Expertise

DevOps
Software Dev
Web Dev

Social Media

twittergithub

Related Posts

Ubuntu 64bit on Raspberry Pi4
Ubuntu 19.10 Eoan on Raspberry Pi4
December 05, 2019
1 min
Swift 5.8 Release Now Available
News
Swift 5.8 Release Now Available
April 06, 2023
1 min
© 2023, All Rights Reserved.

Quick Links

About Us

Legal Stuff

Social Media