visit
Download Swift from -> select the Toolchain archive for Ubuntu 20.04
Extract the archive, then open ~/.bashrc and append this line:
PATH="/.../<absolute-path-to-the-extracted-swift-folder>/usr/bin:$PATH"
Reload .bashrc with source ~/.bashrc
sudo apt-get install \
binutils \
git \
gnupg2 \
libc6-dev \
libcurl4 \
libedit2 \
libgcc-9-dev \
libpython2.7 \
libsqlite3-0 \
libstdc++-9-dev \
libxml2 \
libz3-dev \
pkg-config \
tzdata \
uuid-dev \
zlib1g-dev
swift --version
# you should see something similar to
Swift version 5.5.2 (swift-5.5.2-RELEASE)
Target: x86_64-unknown-linux-gnu
mkdir swift-app
cd swift-app
swift package init --type executable
swift build
.build/debug/swift-app
# or
swift run
# it should print Hello, world!