Skip to content

[install] Add Swiftly to the install page #830

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Mar 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions _data/builds/swiftly_release.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
version: "0.4.0"
version: "1.0.0"
platforms:
- platform: Linux
x86_64: "https://download.swift.org/swiftly/linux/swiftly-0.4.0-x86_64.tar.gz"
arm64: "https://download.swift.org/swiftly/linux/swiftly-0.4.0-aarch64.tar.gz"
x86_64: "https://download.swift.org/swiftly/linux/swiftly-1.0.0-x86_64.tar.gz"
arm64: "https://download.swift.org/swiftly/linux/swiftly-1.0.0-aarch64.tar.gz"
- platform: Darwin
x86_64: "https://download.swift.org/swiftly/darwin/swiftly-0.4.0.pkg"
arm64: "https://download.swift.org/swiftly/darwin/swiftly-0.4.0.pkg"
x86_64: "https://download.swift.org/swiftly/darwin/swiftly-1.0.0.pkg"
arm64: "https://download.swift.org/swiftly/darwin/swiftly-1.0.0.pkg"
31 changes: 31 additions & 0 deletions _includes/install/_linux_platforms_tabs.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
## Latest Release
<ul class="grid-level-0 grid-layout-1-column">
<li class="grid-level-1 featured">
<h3>Swiftly (recommended)</h3>
<p class="description">
The Swiftly installer manages Swift and its dependencies. It supports switching between different versions and downloading updates.
</p>
<h4>Run this in a terminal:</h4>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><button>Copy</button><pre class="highlight"><code>curl -O https://download.swift.org/swiftly/linux/swiftly-$(uname -m).tar.gz &amp;&amp; \
tar zxf swiftly-$(uname -m).tar.gz &amp;&amp; \
./swiftly init --quiet-shell-followup &amp;&amp; \
. ~/.local/share/swiftly/env.sh &amp;&amp; \
hash -r
</code></pre></div></div>
<h4>License: <a href="https://raw.githubusercontent.com/swiftlang/swiftly/refs/heads/main/LICENSE.txt">Apache-2.0</a> | PGP: <a href="https://download.swift.org/swiftly/linux/swiftly-0.4.0-dev-x86_64.tar.gz.sig">Signature</a></h4>
<a href="/install/linux/swiftly" class="cta-secondary">Instructions</a>
</li>
</ul>
<ul class="grid-level-0 grid-layout-1-column">
<li class="grid-level-1">
<h3>Container</h3>
<p class="description">
If you prefer a containerized environment, you can download the official container images for compiling and running Swift on a variety of distributions.
</p>
<a href="https://hub.docker.com/_/swift" class="cta-secondary external">Docker Hub</a>
<a href="/install/linux/docker" class="cta-secondary">Instructions</a>
</li>
</ul>

## Alternate installation options

<p id="platforms">Select Linux platform:</p>

<div class="interactive-tabs os">
Expand Down
2 changes: 1 addition & 1 deletion _includes/install/_os_tabs.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Follow the instructions below to install the latest version of Swift on a [suppo
<div class="interactive-tabs os">
<div class="tabs">
<a href="/install/macos" aria-pressed="{{ include.macos }}">macOS</a>
<a href="/install/linux#platforms" aria-pressed="{{ include.linux }}">Linux</a>
<a href="/install/linux" aria-pressed="{{ include.linux }}">Linux</a>
<a href="/install/windows" aria-pressed="{{ include.windows }}">Windows</a>
</div>
</div>
Expand Down
19 changes: 19 additions & 0 deletions assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,24 @@ layout: source
}
})
}

if (navigator && navigator.clipboard) {
const copyCodeButtons = document.querySelectorAll('[class^="language-"] button');

copyCodeButtons.forEach(function(button) {
const codeElement = button.parentElement.querySelector('code');
const originalText = button.innerText;

button.addEventListener('mousedown', async function() {
await navigator.clipboard.writeText(codeElement.innerText);

button.innerText = 'Copied!';

setTimeout(() => {
button.innerText = originalText;
}, 1000);
});
});
}
});
})();
25 changes: 22 additions & 3 deletions assets/stylesheets/elements/_grid.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
background-color: var(--color-fill-secondary);
border: 1px solid var(--color-fill-tertiary);
border-radius: var(--border-radius);

padding: 1rem;
display: flex;
flex-direction: column;
Expand Down Expand Up @@ -77,7 +77,7 @@
}

// Button typically embedded in a grid-level-1
a.cta-secondary {
a.cta-secondary, [class^="language-"] button {
background-color: var(--color-fill-tertiary);
border: 1px solid var(--color-fill-quaternary);
border-radius: var(--border-radius);
Expand All @@ -99,7 +99,7 @@ a.cta-secondary {
&:hover {
color: var(--color-link);
background-color: var(--color-fill-quaternary);

text-decoration: none;

@media (prefers-contrast: more) {
Expand All @@ -112,3 +112,22 @@ a.cta-secondary {
content: " ↗";
}
}

div.highlight {
position: relative;

&:hover button {
display: block;
}
}

[class^="language-"] button {
cursor: pointer;
padding: 0.1rem 0.4rem;
font-size: 0.8rem;
position: absolute;
right: 0.4rem;
top: 0.4rem;
margin: 0;
display: none;
}
1 change: 0 additions & 1 deletion install/linux/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ title: Install Swift
---

{% include install/_os_tabs.md linux="true" %}

{% include install/_linux_platforms_tabs.md %}
69 changes: 69 additions & 0 deletions install/linux/swiftly/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
layout: page
title: Getting Started with Swiftly on Linux
---

Download swiftly for [Linux (Intel)](https://download.swift.org/swiftly/linux/swiftly-{{ site.data.builds.swiftly_release.version }}-x86_64.tar.gz), or [Linux (ARM)](https://download.swift.org/swiftly/linux/swiftly-{{ site.data.builds.swiftly_release.version }}-aarch64.tar.gz).

```
curl -O https://download.swift.org/swiftly/linux/swiftly-{{ site.data.builds.swiftly_release.version }}-$(uname -m).tar.gz
```

You can verify the integrity of the archive using the PGP signature. This will download the signature, install the swift.org signatures into your keychain, and verify the signature.

```
curl https://www.swift.org/keys/all-keys.asc | gpg --import -
curl -O https://download.swift.org/swiftly/linux/swiftly-{{ site.data.builds.swiftly_release.version }}-$(uname -m).tar.gz.sig
gpg --verify swiftly-{{ site.data.builds.swiftly_release.version }}-$(uname -m).tar.gz.sig swiftly-{{ site.data.builds.swiftly_release.version }}-$(uname -m).tar.gz
```

Extract the archive.

```
tar -zxf swiftly-{{ site.data.builds.swiftly_release.version }}-$(uname -m).tar.gz
```

Run the following command in your terminal, to configure swiftly for your account, and automatically download the latest swift toolchain.

```
./swiftly init
```

Note: You can set the SWIFTLY_HOME_DIR and SWIFTLY_BIN_DIR environment variables to customize your install location.

Your current shell may need some additional steps to update your session. Follow the guidance at the end of the installation for a smooth install experience, such as sourcing the environment file, and rehashing your shell's PATH.

There can be certain packages that need to be installed on your system so that the Swift toolchain can function. The swiftly initialization routine will show you how to install any missing packages.

Now that swiftly and swift are installed, you can access the `swift` command from the latest Swift release:

```
swift --version
--
Swift version {{ site.data.builds.swift_releases.last.name }} (swift-{{ site.data.builds.swift_releases.last.name }}-RELEASE)
Target: x86_64-unknown-linux-gnu
```

Or, you can install (and use) another swift release:

```
swiftly install --use 5.10
swift --version
--
Swift version 5.10 (swift-5.10-RELEASE)
Target: x86_64-unknown-linux-gnu
```

There's also an option to install the latest snapshot release and get access to the latest features:

```
swiftly install --use main-snapshot
```

Check for updates to swiftly and install them by running the self-update command:

```
swiftly self-update
```

You can discover more about swiftly in the [documentation](https://www.swift.org/swiftly/documentation/swiftlydocs/)
36 changes: 28 additions & 8 deletions install/macos/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,45 @@ title: Install Swift

{% include install/_os_tabs.md macos="true" %}

## Latest Release (Swift {{ site.data.builds.swift_releases.last.name }})

<ul class="grid-level-0 grid-layout-2-column">
## Latest Release
<ul class="grid-level-0 grid-layout-1-column">
<li class="grid-level-1 featured">
<h3>Swiftly</h3>
<p class="description">
To download toolchains from Swift.org, use the Swiftly toolchain installer. Swift.org toolchains include experimental features like Embedded Swift and support for WebAssembly.
</p>
<h4>Run this in a terminal:</h4>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><button>Copy</button><pre class="highlight"><code>curl -O https://download.swift.org/swiftly/darwin/swiftly.pkg &amp;&amp; \
installer -pkg swiftly.pkg -target CurrentUserHomeDirectory &amp;&amp; \
~/.swiftly/bin/swiftly init --quiet-shell-followup &amp;&amp; \
. ~/.swiftly/env.sh &amp;&amp; \
hash -r
</code></pre></div></div>
<h4>License: <a href="https://raw.githubusercontent.com/swiftlang/swiftly/refs/heads/main/LICENSE.txt">Apache-2.0</a></h4>
<a href="/install/macos/swiftly" class="cta-secondary">Instructions</a>
</li>
</ul>
<ul class="grid-level-0 grid-layout-1-column">
<li class="grid-level-1">
<h3>Xcode</h3>
<p class="description">
For targeting Darwin platforms, download the latest version of Xcode, which is regularly refreshed with the latest Swift toolchain.
To develop with Swift for Apple platforms, download the latest version of Xcode, which is regularly refreshed with the latest Swift toolchain.
</p>
<a href="https://developer.apple.com/xcode/" class="cta-secondary external">Install Xcode</a>
</li>
</ul>


## Other Install Options
<ul class="grid-level-0 grid-layout-2-column">
<li class="grid-level-1">
<h3>Package Installer</h3>
<p class="description">
For cross-compilation to non-Darwin platforms and Embedded Swift, download the toolchain package installer (.pkg)
The toolchain package installer (.pkg) that Swiftly automates is available as a stand-alone download.
</p>
<a href="https://download.swift.org/{{ site.data.builds.swift_releases.last.tag | downcase }}/xcode/{{ site.data.builds.swift_releases.last.tag }}/{{ site.data.builds.swift_releases.last.tag }}-osx.pkg" class="cta-secondary">Download Toolchain</a>
<a href="/install/macos/package_installer" class="cta-secondary">Instructions</a>
</li>
</ul>

<ul class="grid-level-0">
{% include install/_static_sdk_release.md %}
</ul>

Expand All @@ -40,6 +58,8 @@ title: Install Swift

Swift snapshots are prebuilt binaries that are automatically created from the branch. These snapshots are not official releases. They have gone through automated unit testing, but they have not gone through the full testing that is performed for official releases.

The easiest way to install development snapshots is with the Swiftly tool. Read more on the [instructions page](/install/macos/swiftly).

{% assign xcode_dev_builds = site.data.builds.development.xcode | sort: 'date' | reverse %}
{% assign xcode_6_1_builds = site.data.builds.swift-6_1-branch.xcode | sort: 'date' | reverse %}

Expand Down
57 changes: 57 additions & 0 deletions install/macos/swiftly/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
layout: page
title: Getting Started with Swiftly on macOS
---

Download the [swiftly package for macOS](https://download.swift.org/swiftly/darwin/swiftly-{{ site.data.builds.swiftly_release.version }}.pkg).

Install the package in your user account:

```
installer -pkg swiftly-{{ site.data.builds.swiftly_release.version }}.pkg -target CurrentUserHomeDirectory
```

Run the following command in your terminal, to configure swiftly for your account, and automatically download the latest swift toolchain.

```
~/.swiftly/bin/swiftly init
```

Note: You can set the SWIFTLY_HOME_DIR and SWIFTLY_BIN_DIR environment variables to customize the install location.

<div class="warning" markdown="1">
Your current shell may need some additional steps to update your session. Follow the guidance at the end of the installation for a smooth install experience, such as sourcing the environment file, and rehashing your shell's PATH.
</div>

Now that swiftly and swift are installed, you can access the `swift` command from the latest Swift release:

```
swift --version
--
Apple Swift version {{ site.data.builds.swift_releases.last.name }} (swift-{{ site.data.builds.swift_releases.last.name }}-RELEASE)
Target: arm64-apple-macosx15.0
```

Or, you can install (and use) another swift release:

```
swiftly install --use 5.10
swift --version
--
Apple Swift version 5.10 (swift-5.10-RELEASE)
Target: arm64-apple-macosx15.0
```

There's also an option to install the latest snapshot release and get access to the latest features:

```
swiftly install --use main-snapshot
```

Check for updates to swiftly and install them by running the self-update command:

```
swiftly self-update
```

You can discover more about swiftly in the [documentation](https://www.swift.org/swiftly/documentation/swiftlydocs/)