Skip to content

Commit 218d6a2

Browse files
authored
Merge pull request #1295 from jasonrandrews/tool-installs
Swift install guide
2 parents 619417d + 190498e commit 218d6a2

File tree

1 file changed

+143
-0
lines changed

1 file changed

+143
-0
lines changed

content/install-guides/swift.md

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
---
2+
3+
title: Swift
4+
author_primary: Jason Andrews
5+
6+
minutes_to_complete: 10
7+
additional_search_terms:
8+
- swift
9+
10+
layout: installtoolsall
11+
multi_install: false
12+
multitool_install_part: false
13+
official_docs: https://www.swift.org/documentation/
14+
test_images:
15+
- ubuntu:latest
16+
test_maintenance: true
17+
tool_install: true
18+
weight: 1
19+
---
20+
21+
[Swift](https://swift.org/) is an open-source programming language developed by Apple. It was initially created for use with Apple's iOS, macOS, watchOS, and tvOS operating systems, but has since gained popularity as a general-purpose language suitable for a wide range of Linux and Windows applications. Swift is known for its safety, speed, and expressiveness, making it a great choice for both beginners and experienced programmers.
22+
23+
## What do I need to install Swift?
24+
25+
Swift is available for macOS, Windows, and Linux, including Arm Linux distributions.
26+
27+
This guide provides a quick solution to install Swift on Ubuntu for Arm.
28+
29+
Confirm you are using an Arm machine by running:
30+
31+
```bash
32+
uname -m
33+
```
34+
35+
The output should be:
36+
37+
```output
38+
aarch64
39+
```
40+
41+
If you see a different result, you are not using an Arm computer running 64-bit Linux.
42+
43+
### What software packages are needed?
44+
45+
Before you install Swift on Ubuntu 24.04, install the following packages:
46+
47+
```bash
48+
sudo apt update
49+
sudo apt-get -y install \
50+
binutils \
51+
git \
52+
gnupg2 \
53+
libc6-dev \
54+
libcurl4-openssl-dev \
55+
libedit2 \
56+
libgcc-13-dev \
57+
libncurses-dev \
58+
libpython3-dev \
59+
libsqlite3-0 \
60+
libstdc++-13-dev \
61+
libxml2-dev \
62+
libz3-dev \
63+
pkg-config \
64+
tzdata \
65+
unzip \
66+
zlib1g-dev
67+
```
68+
69+
## How do I download and install Swift?
70+
71+
This guide uses Swift version 6.0.1 on Ubuntu 24.04.
72+
73+
You can get more information about other versions and platforms from [Download Swift](https://www.swift.org/download/).
74+
75+
Download Swift for Arm Linux:
76+
77+
```bash
78+
wget https://download.swift.org/swift-6.0.1-release/ubuntu2404-aarch64/swift-6.0.1-RELEASE/swift-6.0.1-RELEASE-ubuntu24.04-aarch64.tar.gz
79+
```
80+
81+
Extract the archive:
82+
83+
```bash
84+
sudo tar -xf swift-6.0.1-RELEASE-ubuntu24.04-aarch64.tar.gz -C /usr/local
85+
```
86+
87+
Add the `bin/` directory to your search path:
88+
89+
```bash
90+
echo 'export PATH="$PATH:/usr/local/swift-6.0.1-RELEASE-ubuntu24.04-aarch64/usr/bin"' >> ~/.bashrc
91+
source ~/.bashrc
92+
```
93+
94+
## How can I confirm Swift is working?
95+
96+
You can print the version with:
97+
98+
```bash
99+
swift --version
100+
```
101+
102+
The expected output is:
103+
104+
```output
105+
Swift version 6.0.1 (swift-6.0.1-RELEASE)
106+
Target: aarch64-unknown-linux-gnu
107+
```
108+
109+
You can also create and run a simple example program.
110+
111+
Use a text editor to create a new file named `hello.swift` and add the following code:
112+
113+
```swift
114+
print("Hello from Swift on Arm Linux!")
115+
```
116+
117+
Compile and run the program:
118+
119+
```bash
120+
swift hello.swift
121+
```
122+
123+
The output will be:
124+
125+
```output
126+
Hello from Swift on Arm Linux!
127+
```
128+
129+
You can also compile and run the program using:
130+
131+
```bash
132+
swiftc hello.swift -o hello
133+
./hello
134+
```
135+
136+
The output will be the same:
137+
138+
```output
139+
Hello from Swift on Arm Linux!
140+
```
141+
142+
You are ready to use the Swift programming language on your Arm Linux computer.
143+

0 commit comments

Comments
 (0)