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.
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
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
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.
While VSCode has good support for Swift out of the box there are also some great extensions you may want to install.
1 - Code RunnerCode Runner makes it easy to quickly run and test your code.
2 - Swift LanguageThe Swift Language extension adds support for Colorization, Snippets and Grammar
To install an extension simply tap the Install
button.
Create a new file and name it helloworld.swift
Add a simple print statement to print “Hello World!”
print("Hello World!")
3 - Run the code.
Tap the ▷
run button to execute the code.
Congratulations! You now have a working Swift development environment on your Raspberry Pi.
Hope you enjoy coding with Swift on your Raspberry Pi!
Quick Links
Legal Stuff
Social Media