Swift 与 Xcode 版本对照
Xcode 27、27.1 和 27.2 带 Swift 6.4 编译器;Xcode 26.4.1 到 26.6 带 Swift 6.3;Xcode 16 是第一个提供 Swift 6 语言模式的版本,所有 Xcode 都仍提供 Swift 5 模式。声明 .iOS(.v18) 的 Package.swift 需要 swift-tools-version 6.0,也就是 Xcode 16 或更高。下面是 Xcode 14.0 以来每个版本的 Swift 编译器、语言模式、SDK、最低 macOS 和发布日期;任一 Swift 版本对应的最早 Xcode;每个平台声明所需的工具版本;以及一个输入框,告诉你 xcodebuild -version 或 swift --version 的输出代表什么。
我装的是哪个版本?
粘贴终端里 xcodebuild -version 或 swift --version 的输出(两个一起也行)。内容不会离开这个页面。
在上面粘贴输出,即可看到对应的 Xcode 或 Swift。
选择 Xcode 版本
按 Apple 的表,看它带什么、能构建什么。
- Swift 编译器
- 6.4
- 语言模式
- 6, 5, 4.2, 4
- SDK
- iOS 27.2 · macOS 27.2 · tvOS 27.2 · watchOS 27.2 · visionOS 27.2 · DriverKit 27.2
- 运行所需 macOS
- macOS Tahoe 26.6 or later
- 发布日期
- 2026 年 10 月 29 日
- 能读取的 Package.swift
- swift-tools-version 最高 6.4
- 认识的最新平台名称
- .iOS(.v27) .macOS(.v27) .tvOS(.v27) .watchOS(.v27) .visionOS(.v27)
- 发布说明
- Apple 发布说明
选择 Swift 版本
最早带它的 Xcode,以及 swift.org 公布它的日期。
最早带 Swift 6.4 的 Xcode:Xcode 27,发布于 2026 年 9 月 14 日。
表中带它的所有 Xcode:Xcode 27, Xcode 27.1, Xcode 27.2。
swift.org 于 2026 年 9 月 15 日 公布 Swift 6.4。 来源
文章没有提到 Xcode 版本。
我的 Package.swift 需要哪个 swift-tools-version?
选择一个平台声明。所需工具版本是 Apple 文档中首次提供该名称的 PackageDescription 版本。
.iOS(.v18) 需要 // swift-tools-version:6.0 或更高。
Apple 的表中编译器为 Swift 6.0 或更高的最早 Xcode 是 Xcode 16。
清单中的其他设置
| Package.swift 中的写法 | 首次提供的工具版本 | 弃用于 |
|---|---|---|
| swiftLanguageModes: [.v6] | 6.0 | – |
| SwiftLanguageMode.v6 | 6.0 | – |
| .swiftLanguageMode(.v5) | 6.0 | – |
| swiftLanguageVersions: [.v5] | 未说明 | 6.0 |
| .enableUpcomingFeature("…") | 5.8 | – |
| .enableExperimentalFeature("…") | 5.8 | – |
| .interoperabilityMode(.Cxx) | 5.9 | – |
| traits: [...] | 6.1 | – |
| .defaultIsolation(MainActor.self) | 6.2 | – |
| .strictMemorySafety() | 6.2 | – |
| .treatAllWarnings(as: .error) | 6.2 | – |
Swift 5 与 Swift 6 语言模式
- Apple 的表从 Xcode 16 开始列出 Swift 6 语言模式。表中每个 Xcode 都仍列有 Swift 5 模式。
- swift.org 迁移指南原话:“A Package.swift file that uses swift-tools-version of 6.0 enables the Swift 6 language mode for all targets.” 来源
- 使用 6.0 工具版本时,想让某个 target 保持 Swift 5 模式,在它的 swiftSettings 里加 .swiftLanguageMode(.v5)。Xcode 项目中对应的设置是“Swift Language Version”(SWIFT_VERSION)。
- swift.org 发布 Swift 6 时的原话:“Swift 6 now includes a new, opt-in language mode”。 来源
Xcode 与 Swift 版本对照
Apple《SDK and system requirements》表的每一行,从新到旧。发布日期来自 Apple 的 Releases 页面。 Apple 的表 · Releases
| Xcode | Swift | 语言模式 | 发布日期 | iOS SDK | macOS SDK | 运行所需 macOS |
|---|---|---|---|---|---|---|
| Xcode 27.2 27B52 | 6.4 | 6, 5, 4.2, 4 | 2026 年 10 月 29 日 | 27.2 | 27.2 | macOS Tahoe 26.6 or later |
| Xcode 27.1 27A9275 | 6.4 | 6, 5, 4.2, 4 | 2026 年 10 月 15 日 | 27.1 | 27 | macOS Tahoe 26.6 or later |
| Xcode 27 27A266a | 6.4 | 6, 5, 4.2, 4 | 2026 年 9 月 14 日 | 27 | 27 | macOS Tahoe 26.6 or later |
| Xcode 26.6 17F113 | 6.3 | 6, 5, 4.2, 4 | 2026 年 6 月 25 日 | 26.5 | 26.5 | macOS Tahoe 26.2 - macOS Tahoe 26.x |
| Xcode 26.5 17F42 | 6.3 | 6, 5, 4.2, 4 | 2026 年 5 月 11 日 | 26.5 | 26.5 | macOS Tahoe 26.2 - macOS Tahoe 26.x |
| Xcode 26.4.1 17E202 | 6.3 | 6, 5, 4.2, 4 | 2026 年 4 月 16 日 | 26.4 | 26.4 | macOS Tahoe 26.2 - macOS Tahoe 26.x |
| Xcode 26.3 17C529 | 6.2.3 | 6, 5, 4.2, 4 | 2026 年 2 月 26 日 | 26.2 | 26.2 | macOS Sequoia 15.6 - macOS Tahoe 26.x |
| Xcode 26.2 17C52 | 6.2.3 | 6, 5, 4.2, 4 | 2025 年 12 月 12 日 | 26.2 | 26.2 | macOS Sequoia 15.6 - macOS Tahoe 26.x |
| Xcode 26.1.1 17B100 | 6.2.1 | 6, 5, 4.2, 4 | 2025 年 11 月 11 日 | 26.1 | 26.1 | macOS Sequoia 15.6 - macOS Tahoe 26.x |
| Xcode 26.1 17B55 | 6.2.1 | 6, 5, 4.2, 4 | 2025 年 11 月 3 日 | 26.1 | 26.1 | macOS Sequoia 15.6 - macOS Tahoe 26.x |
| Xcode 26.0.1 17A400 | 6.2 | 6, 5, 4.2, 4 | 2025 年 9 月 22 日 | 26 | 26 | macOS Sequoia 15.6 - macOS Tahoe 26.x |
| Xcode 26 17A324 | 6.2 | 6, 5, 4.2, 4 | 2025 年 9 月 15 日 | 26 | 26 | macOS Sequoia 15.6 - macOS Tahoe 26.x |
| Xcode 16.4 16F6 | 6.1 | 6, 5, 4.2, 4 | 2025 年 5 月 28 日 | 18.5 | 15.5 | macOS Sequoia 15.3 - macOS Tahoe 26.1.x |
| Xcode 16.3 16E140 | 6.1 | 6, 5, 4.2, 4 | 2025 年 3 月 31 日 | 18.4 | 15.4 | macOS Sequoia 15.2 - macOS Sequoia 15.x |
| Xcode 16.2 16C5032a | 6.0 | 6, 5, 4.2, 4 | 2024 年 12 月 11 日 | 18.2 | 15.2 | macOS Sonoma 14.5 - macOS Sequoia 15.x |
| Xcode 16.1 16B40 | 6.0 | 6, 5, 4.2, 4 | 2024 年 10 月 28 日 | 18.1 | 15.1 | macOS Sonoma 14.5 - macOS Sequoia 15.x |
| Xcode 16 16A242d | 6.0 | 6, 5, 4.2, 4 | 2024 年 9 月 16 日 | 18 | 15 | macOS Sonoma 14.5 - macOS Sequoia 15.x |
| Xcode 15.4 15F31d | 5.10 | 5, 4.2, 4 | 2024 年 5 月 13 日 | 17.5 | 14.5 | macOS Sonoma 14.x |
| Xcode 15.3 15E204a | 5.10 | 5, 4.2, 4 | 2024 年 3 月 5 日 | 17.4 | 14.4 | macOS Sonoma 14.x |
| Xcode 15.2 15C500b | 5.9 | 5, 4.2, 4 | 2024 年 1 月 8 日 | 17.2 | 14.2 | macOS Ventura 13.5 - macOS Sonoma 14.x |
| Xcode 15.1* 15C65 | 5.9 | 5, 4.2, 4 | 2023 年 12 月 11 日 | 17.2 | 14.2 | macOS Ventura 13.5 - macOS Sonoma 14.x |
| Xcode 15.0.x 15A240d | 5.9 | 5 | 2023 年 9 月 18 日 | 17 | 14 | macOS Ventura 13.5 - macOS Sonoma 14.x |
| Xcode 14.3.1 14E300c | 5.8.1 | 5, 4.2, 4 | 2023 年 6 月 1 日 | 16.4 | 13.3 | macOS Ventura 13.x |
| Xcode 14.3* 14E222b | 5.8 | 5, 4.2, 4 | 2023 年 3 月 30 日 | 16.4 | 13.3 | macOS Ventura 13.x |
| Xcode 14.2 14C18 | 5.7 | 5, 4.2, 4 | 2022 年 12 月 13 日 | 16.2 | 13.1 | macOS Monterey 12.5 - macOS Ventura 13.x |
| Xcode 14.1 14B47b | 5.7 | 5, 4.2, 4 | 2022 年 11 月 1 日 | 16.1 | 13 | macOS Monterey 12.5 - macOS Ventura 13.x |
| Xcode 14.0.x 14A309 | 5.7 | 5, 4.2, 4 | 2022 年 9 月 12 日 | 16 | 12.3 | macOS Monterey 12.5 - macOS Ventura 13.x |
Apple 对 Swift 一栏的定义:“The version of the Swift compiler and the supported Swift language mode in this version of Xcode.”
swift.org 上的 Swift 版本
swift.org 博客上的发布文章。文章提到包含该编译器的 Xcode 时,引用原话。
| Swift | 公布日期 | 文章提到的 Xcode | Apple 表中最早的 Xcode |
|---|---|---|---|
| Swift 6.4 | 2026 年 9 月 15 日 | 未说明 | Xcode 27 |
| Swift 6.3 | 2026 年 3 月 24 日 | 未说明 | Xcode 26.4.1 |
| Swift 6.2 | 2025 年 9 月 15 日 | 未说明 | Xcode 26 |
| Swift 6.1 | 2025 年 3 月 31 日 | Xcode 16.3 “If you're building apps for Apple platforms, Swift 6.1 is included in Xcode 16.3, now available from the App Store.” | Xcode 16.3 |
| Swift 6.0 | 2024 年 9 月 17 日 | 未说明 | Xcode 16 |
| Swift 5.10 | 2024 年 3 月 5 日 | 未说明 | Xcode 15.3 |
| Swift 5.9 | 2023 年 9 月 18 日 | Xcode 15 “The Swift 5.9 compiler is also included in Xcode 15.” | Xcode 15.0.x |
| Swift 5.8 | 2023 年 3 月 30 日 | Xcode 14.3 “The Swift 5.8 compiler is also included in Xcode 14.3.” | Xcode 14.3* |
| Swift 5.7 | 2022 年 9 月 12 日 | Xcode 14 “The Swift 5.7 compiler is also included in Xcode 14.” | Xcode 14.0.x |
2026 年 11 月 1 日 swift.org 安装页提供的是 Swift 6.4.2;Apple 的表中 Xcode 27.2 列的是 Swift 6.4。 来源
已于 2026 年 11 月 1 日 对照 Apple 和 swift.org 的页面核对。
它做不到的事
- •不包括 Xcode 14.0 之前的版本和测试版:Apple 的表里都没有。Apple 的表也没有 Xcode 26.4(只有 26.4.1),所以这里也没有。
- •Linux 和 Windows 上的 Swift 补丁版本不对应任何 Xcode,因为它们不随 Xcode 提供。
- •来源没有说明的格子写“未说明”,不凭记忆或其他网站补齐。
- •不读取你的项目、Mac 或 Package.swift。你粘贴文字进来,什么都不会上传。
- •不判断 App Store Connect 是否接受某个构建。上传期限请看 Xcode SDK 要求页。
常见问题
- Xcode 26 和 Xcode 27 带的是哪个 Swift 版本?
- 按 Apple 的表:Xcode 26 和 26.0.1 带 Swift 6.2;26.1 和 26.1.1 带 6.2.1;26.2 和 26.3 带 6.2.3;26.4.1、26.5 和 26.6 带 6.3;Xcode 27、27.1 和 27.2 带 6.4。
- Swift 6 需要哪个 Xcode?
- Apple 的表中,Xcode 16 是第一个带 Swift 6.0 编译器和 Swift 6 语言模式的版本。这个模式需要主动开启:Xcode 项目通过“Swift Language Version”构建设置(SWIFT_VERSION)选择;Swift 包在 swift-tools-version 6.0 时默认使用它。
- .iOS(.v18) 或 .iOS(.v26) 需要哪个 swift-tools-version?
- Apple 的 PackageDescription 文档写明:.v18 首次出现在 PackageDescription 6.0,.v26 在 6.2,.v27 在 6.4。macOS 15、tvOS 18、watchOS 11 和 visionOS 2 同样是 6.0。在 // swift-tools-version: 一行写这个版本或更高即可。
- 把 swift-tools-version 提高到 6.0,代码会切换到 Swift 6 模式吗?
- 会。swift.org 迁移指南写明:使用 swift-tools-version 6.0 的 Package.swift 会为所有 target 启用 Swift 6 语言模式。想让某个 target 留在 Swift 5,在它的 swiftSettings 里加 .swiftLanguageMode(.v5),或为整个包设置 swiftLanguageModes。
- 怎么查看我用的是哪个 Swift 版本?
- 在终端运行 swift --version。装有 Xcode 时会打印类似“Apple Swift version 6.4 (swiftlang-6.4.0.34.1 ...)”的一行。xcodebuild -version 会打印 Xcode 版本和构建号。把任意一个粘贴到本页的输入框即可。
- Xcode 27 需要什么版本的 macOS?
- Apple 的表写明 Xcode 27、27.1 和 27.2 需要 macOS Tahoe 26.6 或更高。Xcode 26.4.1 到 26.6 需要 macOS Tahoe 26.2,Xcode 26 到 26.3 可在 macOS Sequoia 15.6 或更高版本上运行。