Swiftly 1.0
Swiftly 1.0

原始链接: https://swift.org/blog/introducing-swiftly_10/

截至2025年3月28日,Swift版本管理器swiftly正式成为Swift核心工具链的一部分,简化了在Xcode之外安装、管理和更新Swift工具链的过程。它最初由社区支持用于Linux,现在包含了macOS支持,使得在Linux上使用不同版本的Swift或安装Swift更加容易。 swiftly允许用户安装最新的稳定版本,尝试 nightly 版本,并在多个工具链之间轻松切换。项目中的`.swift-version`文件确保所有团队成员使用相同的Swift版本。该工具本身是用Swift编写的,使用Foundation进行文件系统操作,使用Async HTTP Client进行网络请求,使用Swift OpenAPI插件与swift.org交互,并与C互操作以使用libarchive提取工具链。 通过使用Swift静态Linux SDK和利用操作系统检测,swiftly的安装过程得到了简化。swiftly可在macOS和各种Linux发行版上使用,并为CI/CD环境和企业配置提供了文档。用户可以通过GitHub贡献代码或在Swift论坛上讨论。感谢swiftly的创建者Patrick Freed。

Hacker News 最新 | 过去 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 Swiftly 1.0 (swift.org) 30 分,来自 todsacerdoti,1 小时前 | 隐藏 | 过去 | 收藏 | 2 条评论 zero0529 11 分钟前 [–] 所以这像是 Swift 的 UV 吗?或者有什么好处?我可以抛弃 Xcode 而使用它吗? 回复 nindalf 1 分钟前 | 父评论 [–] 它就像 Swift 的 rustup 或 nvm(Node 版本管理器)。Swiftly 用于安装 Swift。如果你只需要 Xcode 来安装 Swift,那么是的,你可以用 swiftly 替换 Xcode。 回复 加入我们 6 月 16-17 日在旧金山参加 AI 初创公司学校! 指导原则 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系我们 搜索:

原文

Today we’re delighted to introduce the first stable release of swiftly, a Swift version manager that takes the pain out of installing, managing and updating your Swift toolchain.

The latest version of Swift is bundled with Xcode for writing apps for Apple platforms. But perhaps you want to install Swift on a different platform like Linux, or use a different version of the toolchain for building services or command line tools. Downloading, extracting and installing a trusted build of Swift along with the relevant dependencies for your operating system can require quite a few manual and error-prone steps.

swiftly has been around for some years as a community-supported tool for Swift developers using Linux. With this release, we’re officially supporting it as part of the core Swift toolchain, including hosting it as part of the Swift GitHub organization. We’ve also added macOS support to make it easier to install Swift separately from Xcode.

swiftly is the best tool to install the standalone toolchain, providing commands to install Swift on a new system, update to the latest stable version, and experiment or test with nightly snapshots or older versions. It also makes it easy to switch effortlessly between multiple installed toolchains. You can even add a file to your project repository so swiftly will use the same toolchain version for all members of your development team.

Naturally, swiftly itself is written in Swift, and is able to update itself to the latest version.

Let’s take a look at some of the features of swiftly!

To get started, visit swift.org/install and install it.

swiftly will provide directions after installation if there are any system packages, or shell commands needed for smooth operation of the new toolchain.

The latest Swift toolchain is installed as the default, so you can immediately use it to start a new project. For example:

The swiftly use command selects the default toolchain for Swift commands (e.g. swift test, swift build):

$ swiftly use 6.0.3
$ swift --version
--
Apple Swift version 6.0.3 (swiftlang-6.0.3.1.2 clang-1600.0.28.6)
Target: arm64-apple-macosx15.0

At a later point, if there’s a new release of Swift you can install it alongside the existing toolchain with the latest command:

Pre-release of versions of Swift are available, including nightly “snapshot” toolchains. They can be easily listed using swiftly:

$ swiftly list-available main-snapshot
--
Available main development snapshot toolchains
----------------------------------------------
main-snapshot-2025-03-25
...

Once you’ve identified a snapshot toolchain, it can be installed using its name:

$ swiftly install main-snapshot-2025-03-25
--
Installing main-snapshot-2025-03-25

Another way to temporarily use a specific version of Swift is to use the special ‘+’ selector. With this syntax, you don’t need to first switch to a different toolchain:

$ swiftly run lldb +main-snapshot-2025-03-25
--
(lldb) _

If you’re building a SwiftPM project in a team setting and want to enforce a common version of the Swift toolchain on all contributors, simply create a .swift-version file in the root of your project folder with the desired version (e.g. “6.0.3”).

As swiftly is updated with new features and bug fixes, you can run swiftly self-update to check and install new releases.

By writing swiftly in Swift, we’re able to take advantage of the language’s features, support, and ecosystem of related projects. Swift comes with standard library features for working with the filesystem in its Foundation module. For network operations Async HTTP Client is there to work the HTTP requests. And to retrieve the latest Swift release, swiftly uses the Swift OpenAPI plugin to generate the code to interact with the swift.org website. Lastly, it takes advantage of Swift’s interoperability with C to use the existing libarchive library to work with archives. swiftly uses libarchive to extract the toolchains downloaded from the Swift website and the integration is simple.

It can be challenging to build shell programs that work well across multiple platforms with minimal system dependencies; this motivated us to switch swiftly away from using a shell program to install it and become a self-installing binary application. swiftly has access to excellent argument parsing capabilities, beautiful --help screens, and the full standard library.

The only remaining problem was being able to deliver the operating system and processor architecture specific binary to the users system with simplicity. The swift.org website helps with operating system detection, but it cannot reliably detect the Linux distribution. Luckily, there is the Swift Static Linux SDK that makes binaries that work with a wide range of distributions. The processor architecture can be determined on most unixes using uname -m . The result of all of this is the simplicity of a copy and paste from the website to your terminal and get started with Swift.

Moving forward, swiftly will become the default way to install Swift outside of Xcode. The initial version supports macOS and a variety of Linux distributions, including Ubuntu, Debian, Fedora, Red Hat Enterprise Linux and Amazon Linux.

The swiftly documentation provides further information about using swiftly in a CI/CD environment, as well as setting proxy servers and custom install locations for enterprise environments. swiftly is an open source project, and so you can raise new issues or contribute pull requests at its GitHub repository. You can also ask questions or discuss swiftly on the Swift Forums.

Special thanks to Patrick Freed for creating swiftly, contributing it to the Swift organization, and his continued contributions to this valuable tool. The community is what makes Swift amazing!

联系我们 contact @ memedata.com