How to install “Swift” language on Ubuntu 22.04 LTS VM on M1 MacBook Pro

Rajesh Mani
3 min readAug 3, 2023

The motivation behind this article stems from a personal experience wherein I encountered challenges while attempting to install SwiftLang a dependency to run “vapor” server on an Ubuntu server Virtual Machine. The server was hosted on a virtual machine using “VMware Fusion” on an M1 Mac. The particular challenge arose from the fact that the majority of tutorials available were geared towards Ubuntu 22.04 on x86_64 architecture, rendering them incompatible with ARM-based machines like the M1 Mac.

As a result, I felt compelled to address this gap in information and provide a comprehensive guide tailored specifically for ARM architecture installations on M1 Macs.

Requirements:

To successfully install SwiftLang on an ARM64 architecture, such as the one found in Apple M1 Macs, the following prerequisites are necessary:

  1. An Ubuntu 22.04 LTS (Arm64) installed on a virtual machine application compatible with Apple M1 Macs, such as VMware Fusion (version 13.0.2), UTM, or Parallels Desktop.

Step-by-Step Installation Guide:

Step 1:

Launch the Ubuntu 22.04 LTS Virtual Machine on Your M1 Mac

Begin by initiating the Ubuntu 22.04 LTS virtual machine on your M1 Mac. Once the virtual machine is up and running, open the terminal application and execute the following command to update and upgrade your system packages:

sudo apt update && sudo apt upgrade

Step 2:

Execute the below command to install dependencies.

apt-get install \
binutils \
git \
gnupg2 \
libc6-dev \
libcurl4-openssl-dev \
libedit2 \
libgcc-9-dev \
libpython3.8 \
libsqlite3-0 \
libstdc++-9-dev \
libxml2-dev \
libz3-dev \
pkg-config \
tzdata \
unzip \
zlib1g-dev

Step 3: Install “curl” (If Not Already Installed)

If the “curl” utility is not already installed on your system, you can install it using the following command:

sudo apt install curl

Step 4: SwiftLang Installation

Use the “curl” command to swiftly install the script required for SwiftLang installation:

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

Upon successful execution, you will be presented with a list of available Swift versions. Choose the desired Swift version; for instance, I selected Swift 5.7. If you want install latest stable version select “option 1”.

Step 5: Install SwiftLang

Install SwiftLang using the following command:

sudo apt install swiftlang

Please be patient, as this process may take some time to complete. Once the download and installation are finished, you can verify the successful installation by entering ‘swift’ in the terminal. This will display a list of sub-commands along with a welcoming message.

Congratulations! You have now successfully installed SwiftLang on your ARM64 architecture system. You are all set to start utilizing Swift for your programming endeavors. Best of luck!

--

--