Xcode 27 正式推出:系統需求、部署目標,以及哪些東西壞了
Xcode 27 於 2026 年 9 月 14 日以 build 27A266a 正式推出,距離發佈摘要中的 iOS 27.0 RC 項目三天,並與 iOS 27.0(24A437)、macOS 27.0(26A428)及其餘 27 系列平台同日上線;App Store Connect 自 9 月 9 日起已接受以 RC SDK 建置的版本,當天起也開始接受以 27.0 GA SDK 建置的版本。15 它需要 macOS Tahoe 26.6 或更新版本以及 Apple 晶片的 Mac,內含 Swift 6.4 與 27 系列 SDK,可對執行 iOS 17 或更新版本的裝置進行除錯,並提高了三項部署目標下限:macOS 12、watchOS 9 與 DriverKit 21。23 對既有專案而言,它帶來三個硬性失敗(@State 巨集、SE-0508 的原始碼相容性中斷,以及 -ld64 連結器旗標)、一條可能報錯的相依性掃描規則、一項對 ARCHS_STANDARD 的無聲變更,以及兩個警告;除了掃描規則之外,其餘各項我都在 27A266a 上實際執行過,結果詳見下文。246
{.answer-block}
重點摘要
- 日期與 build 編號。 Apple 的發佈摘要將 Xcode 27(27A266a)與全部六個 27.0 作業系統列在 9 月 14 日(週一);其中「iOS 27.0 RC (24A437)」項目標示的日期是 9 月 11 日(週五),也就是 App Store Connect 開始接受 RC SDK 上傳的兩天後,而 GA 版本沿用相同的 build 編號。15 App Store Connect 自己在 9 月 14 日的發行說明也寫明,現在可以將以 Xcode 27 建置的 App 上傳到商店與 TestFlight。5
- 系統需求與下限都變了。 Xcode 26.6 可在 macOS 26.2 上執行,並能對 iOS 15 裝置除錯;Xcode 27 需要 macOS 26.6,只能在 Apple 晶片上執行,且不論是模擬器或實體裝置,都只能對 iOS 17、tvOS 17 與 watchOS 10 或更新版本除錯。最低部署目標由 macOS 11 升至 12、watchOS 8 升至 9、DriverKit 20 升至 21;iOS、iPadOS 與 tvOS 維持 15,visionOS 維持 1。23
- 三個硬性失敗。
@State巨集:Apple 自己的範例,也就是在其他儲存屬性之前先對一個已有宣告處初始值的@State屬性賦值的初始化器,會以variable 'self.title' used before being initialized失敗;同時具有陣列或字典字面值初始值與init存取器的計算屬性,若 getter 寫在前面就無法編譯,Apple 將這項原始碼相容性中斷歸因於 SE-0508;而 Xcode 15 曾寫進文件的-ld64連結器旗標,現在會讓連結以ld: library 'd64' not found失敗。2468 - 四項會警告、可能報錯或毫無提示的變更。 由於 ld64 已經移除,連結器會忽略
-ld_classic並發出警告;同一次相依性掃描中若出現重複的 Clang 模組名稱,「may report an error」(可能會回報錯誤);設定為 27.0 的純 macOS 目標只會建置 arm64,除非您自行把 x86_64 加回去,而且不會有任何警告;PreviewProvider帶有 27.0 的棄用標記與「Use #Preview instead.」訊息,每個 preview 修飾器則各自帶有替代方案訊息,但在部署目標低於 27.0 時,編譯器一律不會顯示這些訊息。24 - 截至 9 月 15 日,Apple 尚未釋出 Xcode 27.1。 發佈摘要與發行說明索引都沒有列出它,Apple 的 iPhone Duo 開發者頁面仍將 27.1 beta 標示為「later this month」(本月稍後);我在 iPhone Duo 開發者文章中描述的 SDK 空窗期依然存在。1
9 月 14 日推出了什麼?
| 項目 | Build | 摘要日期 |
|---|---|---|
| Xcode 27 | 27A266a | 2026 年 9 月 14 日(週一) |
| iOS 27.0 / iPadOS 27.0 | 24A437 | 9 月 14 日(週一);摘要中的「iOS 27.0 RC (24A437)」項目標示為 9 月 11 日(週五),App Store Connect 則自 9 月 9 日(週三)起接受 RC SDK 上傳 |
| macOS 27.0 | 26A428 | 9 月 14 日(週一) |
| tvOS 27.0 | 24J361 | 9 月 14 日(週一) |
| visionOS 27.0 | 24M362 | 9 月 14 日(週一) |
| watchOS 27.0 | 24R364 | 9 月 14 日(週一) |
| App Store Connect | 「You can now upload apps built with Xcode 27 using the SDK for iOS 27.0, iPadOS 27.0, macOS 27.0, tvOS 27.0, visionOS 27.0, and watchOS 27.0 for the App Store, and for internal and external testing through TestFlight.」(現在可以上傳以 Xcode 27 與 27.0 系列 SDK 建置的 App,供 App Store 以及 TestFlight 內外部測試使用。) | 9 月 14 日 |
發行說明的 Overview 一節寫道:「Xcode 27 includes Swift 6.4 and SDKs for iOS 27, iPadOS 27, tvOS 27, watchOS 27, macOS 27, and visionOS 27. Xcode 27 supports on-device debugging in iOS 17 and later, tvOS 17 and later, watchOS 10 and later, and visionOS. Xcode 27 requires a Mac running macOS Tahoe 26.6 or later.」(Xcode 27 內含 Swift 6.4 與 27 系列 SDK,支援對 iOS 17、tvOS 17、watchOS 10 或更新版本以及 visionOS 的裝置除錯,並需要執行 macOS Tahoe 26.6 或更新版本的 Mac。)2 在我這台 Mac 上,xcodebuild -version 印出 Xcode 27.0 Build version 27A266a,swift --version 則印出 Apple Swift version 6.4 (swiftlang-6.4.0.34.1 clang-2100.3.34.1)。4
與 26.6 相比,Xcode 27 有哪些系統需求?
升級建置機器之前,最該查的文件就是 Apple 的相容性表格。以下將兩列並排比較:3
| Xcode 26.6 | Xcode 27 | |
|---|---|---|
| 執行所需的 macOS | Tahoe 26.2 至 26.x | Tahoe 26.6 或更新版本,僅限 Apple 晶片2 |
| SDK | iOS、tvOS、watchOS、visionOS、macOS 26.5;DriverKit 25.5 | iOS、tvOS、watchOS、visionOS、macOS 27;DriverKit 27 |
| 部署目標 | iOS 15、tvOS 15、watchOS 8、visionOS 1、macOS 11、DriverKit 20 | iOS 15、tvOS 15、watchOS 9、visionOS 1、macOS 12、DriverKit 21 |
| 可除錯的裝置 | iOS 15、tvOS 15、watchOS 8、visionOS 1 或更新版本 | iOS 17、tvOS 17、watchOS 10、visionOS 1 或更新版本 |
| 模擬器 | iOS 15、tvOS 15、watchOS 8、visionOS 1 或更新版本 | iOS 17、tvOS 17、watchOS 10、visionOS 1 或更新版本 |
| Swift 編譯器 | 6.3 | 6.4(語言模式 6、5、4.2、4) |
這幾列背後藏著兩個後果。Instruments 現在會拒絕比 iOS 17、watchOS 10 或 tvOS 17 更舊的裝置,所以用舊 iPhone 搭起來的效能分析環境,會比任何 App 程式碼更早失效。2 另外,Apple 用一句話界定了 Device Hub 鍵盤與指標互動的支援範圍:「only supported on the following OS versions and newer: macOS 15.0, iOS 18.0, tvOS 18.0, watchOS 11.0, visionOS 2.0.」(僅支援 macOS 15.0、iOS 18.0、tvOS 18.0、watchOS 11.0、visionOS 2.0 及更新版本。)2
Apple 晶片的要求對執行 Xcode 的那台 Mac 沒有任何變通辦法,而對讀過七月那篇 Intel 文章的人來說也不是新聞;GA 版說明完整保留了七月的措辭:「Xcode 27 will only install and run on Apple silicon Macs. The macOS 27 SDK supports back deploying Universal (Intel and Apple Silicon) apps to macOS 12 and later. Intel development is still possible with macOS versions that support Rosetta like macOS 27.」(Xcode 27 只能安裝並執行於 Apple 晶片 Mac;macOS 27 SDK 支援將 Universal App 回溯部署到 macOS 12 及更新版本;在支援 Rosetta 的 macOS 版本上,例如 macOS 27,仍可進行 Intel 開發。)2 第三句話說的是您出貨對象的 Mac 有變通辦法,而不是您用來建置的那台。
工具鏈有哪些變更?
連結器。 GA 版說明用一句話交代:「The ld64 linker has been removed and the -ld_classic option is no longer supported.」(ld64 連結器已移除,-ld_classic 選項不再受支援。)2 在 27A266a 上實際的樣貌是:工具鏈的 usr/bin 只剩一個連結器執行檔 ld,它回報自己是 2026 年 8 月 25 日建置的 ld-27037.1。傳入舊旗標並不會讓連結失敗。以只含 int main(void){return 0;} 這一行的 hello.c 為例,clang hello.o -o hello_classic -Xlinker -ld_classic 會印出 ld: warning: -ld_classic is no longer supported and will be ignored,以 0 結束並寫出執行檔。Apple 在 Xcode 15 文件中記載的另一種寫法 -ld64 就沒這麼幸運了:8 clang hello.c -o hello_ld64 -Wl,-ld64 會以 ld: library 'd64' not found 失敗並以 1 結束,因為新連結器把 -ld64 讀成 -l d64,也就是要求連結一個名為 d64 的函式庫。4 所以在 OTHER_LDFLAGS 裡帶著 -ld_classic 的專案仍能建置,只是每次連結都多一個新警告,而它原本從舊連結器換來的任何行為都已不復存在;帶著 -ld64 的專案則會停止連結,而且錯誤訊息從頭到尾不會提到連結器。我的 ld64 文章追溯了這些旗標的來源,並記錄了這兩次執行結果。
預設架構。 Intel Deprecation 一節說明了規則:「Build targets with a min deployment target set to macOS 27.0 or DriverKit 27.0 will not build Universal by default. The ARCHS_STANDARD build setting will no longer include x86_64 when MACOSX_DEPLOYMENT_TARGET or DRIVERKIT_DEPLOYMENT_TARGET >= 27.0.」(最低部署目標設為 macOS 27.0 或 DriverKit 27.0 的建置目標,預設不再建置 Universal;當 MACOSX_DEPLOYMENT_TARGET 或 DRIVERKIT_DEPLOYMENT_TARGET >= 27.0 時,ARCHS_STANDARD 建置設定不再包含 x86_64。)2 我在一個多平台專案(Yawara,SUPPORTED_PLATFORMS = iphoneos iphonesimulator macosx xros xrsimulator)上以 xcodebuild -showBuildSettings -sdk macosx 重現了這一點;不加 -sdk 引數時,這個專案根本解析不出任何 ARCHS_STANDARD,這個細節 Intel 文章有說明。在 MACOSX_DEPLOYMENT_TARGET = 26.0 時,該設定解析為 ARCHS_STANDARD = arm64 x86_64;在 27.0 時解析為 ARCHS_STANDARD = arm64,而 ARCHS_STANDARD_64_BIT 在兩種情況下都維持 arm64 x86_64。4 沒有任何警告。如果您出貨 Universal 版本又要提高部署目標,請自行把 x86_64 加進 ARCHS。
C++ 標準函式庫。 「The minimum supported deployment target on macOS for the C++ standard library has been increased to 11.0.」(C++ 標準函式庫在 macOS 上的最低支援部署目標已提高到 11.0。)說明並在「Potentially breaking changes」(可能造成中斷的變更)之下列出行為變更,首先是 multi{map,set}::find 不再保證回傳第一個相符的元素。2 新功能清單很長:std::chrono 值的雜湊、zip、std::optional<T&>、std::views::indices(n) 等等。2
相依性掃描,以及可能讓它失敗的規則。 Apple 表示已將 Swift 相依性掃描器最佳化,「to avoid redundant setup work and header searches when looking up Clang modules during a single dependency-scan action」(以避免在單次相依性掃描動作中查找 Clang 模組時重複進行設定與標頭搜尋),而這項提速附帶一個要求:「every Clang module reachable from a single Swift dependency-scan action must have a unique module name. If two module maps visible to the same scan declare a Clang module with the same name, the scan may report an error. Previously, the scanner may have tolerated duplicating names.」(單次 Swift 相依性掃描動作可及的每個 Clang 模組都必須有唯一的模組名稱;若同一次掃描可見的兩個 module map 宣告了同名的 Clang 模組,掃描可能會回報錯誤;先前的掃描器可能容忍了重複名稱。)2 Apple 點名了兩種會踩到這條規則的情形:「projects or SDKs that vend the same Clang module name from more than one location on the header search path, and vendored third-party sources that ship a module.modulemap redeclaring an SDK module.」(在標頭搜尋路徑上從多個位置提供同一個 Clang 模組名稱的專案或 SDK,以及隨附 module.modulemap 而重新宣告 SDK 模組的內嵌第三方原始碼。)2 和移除連結器一樣,這條規則在工具鏈升級時就會觸發,與部署目標無關;我的 ld64 文章讓兩個互相衝突的 module map 跑過掃描器,編譯了一個會遮蔽 SDK 模組的內嵌 SQLite3 墊片,並針對這兩種情形稽核了七個專案。
哪些程式碼不再能編譯?
@State 巨集。 這項變更寫在 iOS 27 的發行說明而非 Xcode 的說明裡,而且它取決於您用來建置的編譯器,而不是部署的目標:「Xcode 27 introduces a new @State implementation that avoids this repeated evaluation. This new behavior back-deploys to iOS 17 aligned OSes. The new @State is implemented with a Swift macro. It is largely source compatible with the property wrapper version, with a few exceptions.」(Xcode 27 引入了新的 @State 實作以避免重複求值,這項新行為可回溯部署到與 iOS 17 同期的作業系統;新的 @State 以 Swift 巨集實作,與屬性包裝器版本大致上原始碼相容,僅有少數例外。)6 Apple 列出四個例外,其中兩個附有程式碼清單,另外兩個各只有一兩句話:「In rare situations, the automatic inference of generic arguments of @State is less flexible with the macro implementation. Write the type with more specificity.」(在少數情況下,巨集實作對 @State 泛型引數的自動推斷較不靈活,請把型別寫得更明確。)以及「Composing @State with other property wrappers or macros is not supported.」(不支援將 @State 與其他屬性包裝器或巨集組合使用。)6 附有程式碼清單的那兩個,才是會逮到既有程式碼的。一個初始化器對已有宣告處初始值的 @State 屬性賦值:SwiftUI 向來會捨棄這個賦值,而現在「some such cases no longer compile.」(其中某些情形不再能編譯。)6 還有當所有儲存成員都是 private 時編譯器合成的 private 逐成員初始化器:「The state macro disables this synthesized initializer. So the code above no longer compiles.」(state 巨集停用了這個合成的初始化器,因此上面的程式碼不再能編譯。)6 在 27A266a 上,第一個範例照原樣就會失敗,在對 page 賦值的那一行出現 error: variable 'self.title' used before being initialized,因為巨集的 setter 在 title 存在之前就對 self 執行;把 self.title = title 移到它上面,同一個檔案就能編譯,而 @State 的賦值也一如既往地被捨棄。46 第二個範例,也就是在 @State 沒有宣告處初始值的 struct 上,由 extension 呼叫 self.init(page: page, title: title),在我的測試中不做任何修改就能編譯,而巨集展開結果顯示了讓它成立的形態:巨集會產生 private var _page: SwiftUICore.State<StickerPage>,並搭配一個 @storageRestrictions(initializes: _page) init 存取器,這正是讓逐成員初始化器能接受 page: 的構造。4 請把這份說明當成需要檢查的形態清單,然後在自己的程式碼上逐一確認。@State 巨集文章統計了四個上架 App 中這兩種模式的出現次數;那篇文章是我七月根據 beta 說明寫的,早於這次 GA 測試,而它留下的未解問題也在此收尾:在初始化器中直接對後備儲存賦值,也就是 _page = State(initialValue:),不論有沒有宣告處初始值,在 27A266a 上都能編譯。4
SE-0508 的中斷。 在 Swift Compiler 的 Known Issues 之下:「A computed property with both an init accessor and an array/dictionary literal initial value will no longer compile if the getter is declared before the init accessor.」(同時具有 init 存取器與陣列/字典字面值初始值的計算屬性,若 getter 宣告在 init 存取器之前,將不再能編譯。)接著是一段程式碼清單,然後是歸因:「This is a known source break from SE-0508.」(這是 SE-0508 已知的原始碼相容性中斷。)完整的因應方式是:「Swap the init accessor and the getter such that the init accessor is declared first.」(將 init 存取器與 getter 對調,讓 init 存取器先宣告。)2 SE-0508 是「Array expression trailing closures」(陣列運算式尾隨閉包),已在 Swift 6.4 實作,而提案本身就預料到了這個情形:「If the getter is declared before the init accessor, we will now attempt to parse as a trailing closure.」(若 getter 宣告在 init 存取器之前,現在會嘗試解析為尾隨閉包。)並補充「init accessors are however considered for disambiguation, so swapping the accessors is sufficient to make this valid regardless of initial value used.」(不過 init 存取器會納入消歧義的考量,所以無論初始值為何,對調存取器就足以讓程式碼合法。)而且這個情形「does not appear in the source compatibility suite, or for internal Swift projects at Apple.」(沒有出現在原始碼相容性測試套件中,也沒有出現在 Apple 內部的 Swift 專案中。)7 用一個九行的 struct 就能重現。getter 在前時,swiftc 會在存取器那一行以 error: initializers may only be declared within a type 失敗;把 @storageRestrictions(initializes:) 的 init 存取器移到 get 上方,同一個檔案就能編譯。4
struct Container {
private var storage: [Int] = []
var items: [Int] = [] {
@storageRestrictions(initializes: storage)
init(initialValue) { storage = initialValue } // 必須在 get 之前
get { storage }
set { storage = newValue }
}
}
PreviewProvider。 Previews 一節列出一項棄用:「PreviewProvider and its family of preview modifiers.」(PreviewProvider 及其一系列 preview 修飾器。)2 SDK 裡確實帶著這項棄用,協定本身有一則訊息,每個修飾器則各有不同的訊息。在 iOS 27 SDK 的 SwiftUI 介面中,public protocol PreviewProvider 位於 @available(anyAppleOS, deprecated: 27.0, message: "Use #Preview instead.") 之下;previewLayout 的訊息是「Use #Preview(traits: .sizeThatFitsLayout) or .fixedLayout(width:height:) instead.」;previewDisplayName 是「Use #Preview("name") instead.」;previewInterfaceOrientation 是「Use #Preview(traits: .landscapeLeft) or other orientation traits instead.」;previewDevice 是「Use the device picker in Xcode’s canvas.」(改用 Xcode 畫布中的裝置選擇器。);而 previewContext 連同 PreviewContext 與 PreviewContextKey 協定的訊息是「Use #Preview with a Widget timeline provider or entries instead.」(改用搭配 Widget timeline provider 或 entries 的 #Preview。)4 您到底看不看得到這些訊息,由兩個事實決定。編譯器會拿棄用版本與部署目標比較,所以這些修飾器只會在最低部署目標為 27.0 的目標中發出警告:一個使用 previewLayout、previewDisplayName 與 previewDevice 的檔案,在 -target arm64-apple-ios27.0-simulator 下產生三個警告,在 17.0 或 26.0 下則一個都沒有。而 PreviewProvider 本身從不發出警告,原因則不同。SDK 在 anyAppleOS 棄用標記的正上方以 @available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) 宣告它,而在我的探測中,帶有這組標記的協定在 27.0 目標下,不論是遵循它還是把它當作參數型別使用,都不會產生警告;同一個協定若只以 @available(iOS, deprecated: 27.0) 棄用,或只以 anyAppleOS 形式棄用,兩種情況都會警告。修飾器在自身宣告上只帶有 anyAppleOS 棄用標記(容納它們的 extension SwiftUICore.View 帶有 introduced 屬性,而這種繼承而來的形式並不會壓制警告),這就是修飾器會警告而協定不會的原因。4 在任何實際出貨的部署目標下,建置記錄兩者都一片安靜,所以請搜尋 PreviewProvider 與那些修飾器並改用 #Preview;透過新的 #Preview(arguments:) 語法,畫布現在會依每個引數以網格方式呈現預覽。24
System 的新 stat()。 System 函式庫現在為 stat、lstat、fstat 與 fstatat 提供 Swift API,並附有 Stat 型別與 FilePath.stat() 實例方法。2 說明將一個衝突列為已修正:某個 extension 呼叫未限定的 stat() 時,會與這些新方法撞名;如果您在那個衝突還存在時加上了 Darwin. 限定詞,可以留著不動。2
Address Sanitizer,方向相反的問題。 「Address Sanitizer might fail to launch on iOS 27.0, tvOS 27.0, watchOS 27.0, and visionOS 27.0 when building with Xcode 26.4 or older.」(以 Xcode 26.4 或更舊版本建置時,Address Sanitizer 在 iOS 27.0、tvOS 27.0、watchOS 27.0 與 visionOS 27.0 上可能無法啟動。)因應方式是改用 Xcode 26.5 或更新版本;對於 CI 機器上還留著較舊 Xcode、而裝置已更新到 27.0 的團隊來說,這一點很重要。2
IDE 與工具有哪些變更?
- Interface Builder 不需要模擬器也能建置。 新增的
toolchain編譯模式「for UIKit (Cocoa Touch) based documents. Enabled by default,toolchainallows compiling IB documents without the need to download a simulator, which is especially useful for build servers.」(適用於 UIKit(Cocoa Touch)文件,預設啟用,讓 IB 文件不必下載模擬器即可編譯,對建置伺服器特別有用。)2 - 模擬器啟動更快,還能重新開機。 「The simulator runtimes now contain a pre-built dyld cache. This will make first launch of a simulator much faster.」(模擬器執行環境現在內含預先建置的 dyld 快取,首次啟動模擬器會快得多。)而
simctl新增了reboot指令。2 有一個已知問題仍然存在,用 Apple 的話說:「Some simulator runtimes are not completely deleted when removed, re-appearing after a reboot.」(部分模擬器執行環境移除時未完全刪除,重新開機後會再度出現。)2 - devicectl 的 JSON 來到第 5 版。
xcrun devicectl --version回報 642.16,list devices --json-output寫出"jsonVersion": 5;Apple 棄用了hardwareProperties、deviceProperties與connectionProperties欄位,改以properties字典取代,任何仍含有這些欄位的結果都會帶有_deprecationNotice。24 - StoreKit 測試。 StoreKit 設定 UI 可以定義優惠代碼,您可以設定訂閱組合以供本機測試,Transaction Manager 也能在不連接裝置的情況下演練帶有優惠代碼的購買。2
- Organizer。 新增的 Insights Overview「summarizes high-impact performance regressions」(彙整高影響度的效能退化),而 Hitches 指標取代了 Scrolling 指標。2
- 程式碼助理。 Google Gemini 加入模型清單,而且「Planning with agents is now first class in Xcode」(代理規劃現在是 Xcode 的一等功能),計畫以可編輯的 Markdown 成品呈現,經您核准後代理才會繼續執行;我的程式碼代理文章介紹了 beta 時期的工作流程,GA 版說明則列出了專為這類成品設計的 Markdown 編輯器。2
- 本地化。 代理可以翻譯 String Catalog 的項目,匯出本地化內容時也會從標頭檔中擷取
NSLocalizedString及類似的巨集。2 - Icon Composer。 說明稱之為 Icon Composer 2.0,「a new sharper rendering mode for upcoming 2027 operating systems」(為即將推出的 2027 年作業系統提供更銳利的全新算繪模式);27A266a 內附的套件回報版本為 27.0。24
- 測試。 測試計畫可以設定 Xcode 在 UI 測試期間如何處理目標 App 當機,從關閉到視為致命失敗皆可,而
swift test新增了--maximum-repetitions搭配--repeat-until [pass|fail],並在結尾附上失敗摘要。2 - 除錯。 使用橋接標頭時,LLDB「can now directly import explicitly built Swift modules and PCH from DerivedData」(現在可以直接從 DerivedData 匯入明確建置的 Swift 模組與 PCH),而
language swift task tree指令可列出 Swift 並行任務。2
這一週我會做什麼
- 動 CI 之前先讀相容性表格:建置用的 Mac 要有 macOS 26.6,只限 Apple 晶片,最舊的測試裝置是 iOS 17,再加上您的產品適用的 macOS 12、watchOS 9 或 DriverKit 21。23
- 以 grep 搜尋
-ld_classic與-ld64並兩者都移除;連結器會忽略前者並在每次連結時發出警告,遇到後者則直接失敗。既然已經在建置設定裡,順便找找手寫的、會重新宣告 SDK 模組的module.modulemap檔案,也就是 Apple 為唯一模組名稱規則點名的情形。24 - 如果您把任何 macOS 或 DriverKit 目標設為 27.0 而且出貨 Intel 版本,請明確設定
ARCHS;只靠ARCHS_STANDARD只會得到 arm64,這一點我在 macOS 上重現了,Apple 則表示兩者皆然。24 - 搜尋
PreviewProvider、previewLayout、previewDisplayName與previewDevice,並依照各自標記的訊息處理:協定改為#Preview,previewLayout改為#Preview(traits: .sizeThatFitsLayout)或.fixedLayout(width:height:),previewDisplayName改為#Preview("name"),previewDevice改用畫布中的裝置選擇器。這些修飾器只在部署目標為 27.0 時警告,而PreviewProvider的遵循在任何目標下都不會警告,所以實際出貨目標的建置記錄會一直保持安靜。4 - 用 Xcode 27 建置一次,並留意兩則診斷訊息:在其他儲存屬性之前先對已有宣告處初始值的
@State屬性賦值的初始化器,會出現variable 'self.title' used before being initialized,@State 巨集文章有逐步說明;同時具有陣列或字典字面值初始值與 init 存取器的屬性,則會出現initializers may only be declared within a type,此時把存取器移到 getter 上方即可。246 - 既然 App Store Connect 已接受 27 系列 SDK,現在就上傳一個 TestFlight 版本,並記得啟動畫面規定與 UIKit scene 強制規範,因為 App 一旦連結 27 SDK,兩者就會立即生效。56
常見問題
Xcode 27 什麼時候推出?
2026 年 9 月 14 日(週一),build 27A266a,與 iOS 27.0、iPadOS 27.0、macOS 27.0、tvOS 27.0、visionOS 27.0 及 watchOS 27.0 同日推出;發佈摘要將 iOS 27.0 RC(24A437)項目標示為 9 月 11 日,也就是 App Store Connect 開始接受 RC SDK 版本的兩天後。15
Xcode 27 需要哪個版本的 macOS?
Apple 晶片 Mac 上的 macOS Tahoe 26.6 或更新版本。它無法在 Intel Mac 上安裝或執行。它可以在同日推出的 macOS 27.0 上執行。23
Xcode 27 的最低部署目標是什麼?
iOS 15、iPadOS 15、tvOS 15、watchOS 9、visionOS 1、macOS 12 與 DriverKit 21。與 Xcode 26.6 相比,watchOS 從 8 提高、macOS 從 11 提高、DriverKit 從 20 提高。3
Xcode 27 還能建置 Universal 的 Mac App 嗎?
可以,最低可到 macOS 12,但當目標的 MACOSX_DEPLOYMENT_TARGET 為 27.0 時就不再是預設行為:此時 ARCHS_STANDARD 只會解析為 arm64,需要您自行把 x86_64 加進 ARCHS。24
Xcode 27.1 推出了嗎?
截至 2026 年 9 月 15 日尚未推出。Apple 的發佈摘要與 Xcode 發行說明索引都只列出 Xcode 27,Apple 的 iPhone Duo 開發者頁面仍將 Xcode 27.1 beta 標示為「Coming later this month」(本月稍後推出);iPhone Duo SDK 不在這次發行之列。1
Xcode 27 的發行說明在哪裡?
在 Apple 開發者文件網站的 Xcode Release Notes 之下,該版本有專屬的一頁;本文引用的章節包括 Overview、Linking、Intel Deprecation、Previews、Swift Compiler、Address Sanitizer、Instruments、Device Hub、devicectl、Simulator、Interface Builder、C++ Standard Library、Organizer、Coding Intelligence、Source Editor、Icon Composer、StoreKit Testing in Xcode、Localization、Testing、Swift Package Manager、Debugging 與 System。2 @State 巨集的變更則寫在 iOS 與 iPadOS 27 的發行說明中,位於 SwiftUI 一節。6
資料來源
-
Apple,Releases,RSS 摘要擷取於 2026 年 9 月 15 日:「Xcode 27 (27A266a)」、「iOS 27.0 (24A437)」、「iPadOS 27.0 (24A437)」、「macOS 27.0 (26A428)」、「tvOS 27.0 (24J361)」、「visionOS 27.0 (24M362)」、「watchOS 27.0 (24R364)」與「App Store Connect Update」均標示為 2026 年 9 月 14 日(週一);「iOS 27.0 RC (24A437)」標示為 2026 年 9 月 11 日(週五)。Xcode Release Notes 索引只列出一個 27 的項目「Xcode 27 Release Notes」;兩處都沒有出現 27.1 的項目。Apple Developer,Get Ready for iPhone Duo,擷取於 2026 年 9 月 15 日:「Xcode 27.1 beta. Get the latest SDKs to build, run, and test your app for iPhone Duo. Coming later this month」。 ↩↩↩↩↩
-
Apple,Xcode 27 Release Notes,GA 發行後於 2026 年 9 月 15 日擷取。引用的章節:Overview;Linking 的 Deprecations(「The ld64 linker has been removed and the
-ld_classicoption is no longer supported.」165165518);Intel Deprecation 的 New Features(ARCHS_STANDARD,161837535)與 Deprecations(僅限 Apple 晶片,全文引用,162138432);Previews 的 Deprecations(「PreviewProviderand its family of preview modifiers.」144168701)與 New Features(#Preview(arguments:),167544057);Swift Compiler 的 New Features(相依性掃描器與唯一模組名稱要求,節錄,136303612)與 Known Issues(SE-0508,180969028;因應方式那句話全文引用);System 的 New Features 與 Resolved Issues(177911316);Address Sanitizer 的 Known Issues(178072780);Instruments 的 Deprecations(166097304);Device Hub 的 Deprecations(160482487);devicectl 的 New Features(170812159)與 Deprecations(183772705);Simulator 的 New Features(179846743、172303413)與 Known Issues(141290052);Interface Builder 的 New Features;C++ Standard Library 的 New Features 與 Deprecations;Organizer;Coding Intelligence(171990272、172857081);Source Editor 的 New Features(Markdown 編輯器,175022151);Localization;Icon Composer;StoreKit Testing in Xcode;Testing;Swift Package Manager 的 New Features(--maximum-repetitions,177561078;失敗摘要,168311253);Debugging。 ↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩ -
Apple,Xcode support: minimum requirements and supported SDKs,擷取於 2026 年 9 月 15 日。Xcode 27 那一列:macOS Tahoe 26.6 或更新版本;SDK 為 iOS 27、tvOS 27、watchOS 27、visionOS 27、macOS 27、DriverKit 27;部署目標為 iOS 15 至 27、iPadOS 15 至 27、tvOS 15 至 27、watchOS 9 至 27、visionOS 1 至 27、macOS 12 至 27、DriverKit 21 至 27;裝置支援為 iOS 17、tvOS 17、watchOS 10、visionOS 1 或更新版本;模擬器為 iOS 17、tvOS 17、watchOS 10、visionOS 1 或更新版本;Swift 6.4 編譯器,語言模式 6、5、4.2 與 4。Xcode 26.6 那一列:macOS Tahoe 26.2 至 26.x;SDK 為 26.5 版並搭配 DriverKit 25.5;部署目標為 iOS 15、tvOS 15、watchOS 8、visionOS 1、macOS 11、DriverKit 20;裝置與模擬器支援自 iOS 15、tvOS 15、watchOS 8、visionOS 1 起;Swift 6.3。 ↩↩↩↩↩↩
-
作者於 2026 年 9 月 15 日在 Xcode 27.0(27A266a)上的重現,
DEVELOPER_DIR指向該版本,macOS 26.6.2(25G83)。xcodebuild -version:「Xcode 27.0 Build version 27A266a」;swift --version:「Apple Swift version 6.4 (swiftlang-6.4.0.34.1 clang-2100.3.34.1)」;工具鏈的usr/bin只列出一個連結器ld,ld -v印出「PROJECT:ld-27037.1」,建置日期「Aug 25 2026」;以內容為int main(void){return 0;}的hello.c測試,clang hello.o -o hello_classic -Xlinker -ld_classic印出「ld: warning: -ld_classic is no longer supported and will be ignored」並以 0 結束,clang hello.c -o hello_ld64 -Wl,-ld64則印出「ld: library ‘d64’ not found」與「clang: error: linker command failed with exit code 1 (use -v to see invocation)」,以 1 結束且沒有輸出檔。在 Yawara.xcodeproj 上執行xcodebuild -showBuildSettings -sdk macosx,這是一個多平台專案(SUPPORTED_PLATFORMS = iphoneos iphonesimulator macosx xros xrsimulator),不加-sdk引數時不會印出任何ARCHS_STANDARD行:MACOSX_DEPLOYMENT_TARGET = 26.0時ARCHS_STANDARD = arm64 x86_64,27.0 時ARCHS_STANDARD = arm64,兩者的ARCHS_STANDARD_64_BIT = arm64 x86_64。九行的Containerstruct,含var items: [Int] = []與@storageRestrictions(initializes: storage) init(initialValue)存取器:getter 在前時於init那一行以「error: initializers may only be declared within a type」失敗;存取器在前時編譯成功,以 0 結束。iPhoneOS 27.0 SDK 中的SwiftUI.swiftmodule/arm64e-apple-ios.swiftinterface:@available(anyAppleOS, deprecated: 27.0, message: "Use #Preview instead.")位於第 14971 行(public protocol PreviewProvider)、14978 行(其 extension)與 14991 行(PreviewPlatform);「Use #Preview with a Widget timeline provider or entries instead.」位於 15023 行(PreviewContextKey)、15029 行(PreviewContext)與 15069 行(previewContext);「Use the device picker in Xcode’s canvas.」位於 15053 行(previewDevice);「Use #Preview(traits: .sizeThatFitsLayout) or .fixedLayout(width:height:) instead.」位於 15058 行(previewLayout);「Use#Preview("name")instead.」位於 15063 行(previewDisplayName);「Use #Preview(traits: .landscapeLeft) or other orientation traits instead.」位於 15075 行(previewInterfaceOrientation);對一個單純遵循PreviewProvider的檔案執行swiftc -c,在-target arm64-apple-ios27.0-simulator、ios26.0或ios17.0下都沒有發出警告;一個在PreviewProvider內套用previewLayout(.sizeThatFits)、previewDisplayName("Card")與previewDevice(PreviewDevice(rawValue: "iPhone 18 Pro"))的檔案,在ios27.0下發出三個[#DeprecatedDeclaration]警告(「’previewLayout’ was deprecated in any Apple OS 27.0: Use #Preview(traits: .sizeThatFitsLayout) or .fixedLayout(width:height:) instead.」,以及對應的previewDisplayName與previewDevice訊息),在ios26.0或ios17.0下則沒有。一個含四個協定的探測檔案,每個協定各有一個遵循它的 struct,並在同一個函式簽名中有一個any P參數,以-target arm64-apple-ios27.0-simulator編譯:單獨的@available(iOS, deprecated: 27.0)、單獨的@available(anyAppleOS, deprecated: 27.0),以及@available(iOS 13.0, *)疊在@available(iOS, deprecated: 27.0)之上的三種寫法,都在遵循那一行與any P參數型別上發出警告(「’P1’ was deprecated in iOS 27.0」、「’P2’ was deprecated in any Apple OS 27.0」、「’P4’ was deprecated in iOS 27.0」),而 SDK 使用的那組,也就是@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)疊在@available(anyAppleOS, deprecated: 27.0)之上,兩處都沒有警告;透過這些存在型別呼叫方法時,四種寫法都沒有任何診斷訊息,而在ios26.0下四種都沒有警告。在介面檔中,PreviewProvider位於第 14970 至 14972 行,正是那組標記之下;previewLayout位於第 15058 至 15059 行,其自身宣告只帶有anyAppleOS棄用標記,並位於一個extension SwiftUICore.View之內,該 extension 的 introduced 屬性在第 15051 行。一個含兩個 view 的檔案,都在init(title:)內執行_page = State(initialValue: StickerPage(title: title)),一個宣告@State private var page: StickerPage,另一個宣告@State private var page = StickerPage(),在ios27.0下編譯成功,以 0 結束且沒有診斷訊息。@State探測,每個都是含@State private var page與let title: String的StickerPageView,以swiftc -c -target arm64-apple-ios27.0-simulator針對 iPhoneSimulator 27.0 SDK 編譯:Apple 的第一個範例,@State private var page = StickerPage()搭配先賦值self.page再賦值self.title的init(title:),在self.page那一行以「error: variable ‘self.title’ used before being initialized」失敗,以 1 結束;同一個檔案把self.title = title移到self.page賦值之上後編譯成功,以 0 結束;Apple 的第二個範例,@State private var page: StickerPage沒有初始值,並由 extension 呼叫self.init(page: page, title: title),編譯成功,以 0 結束,而-Xfrontend -dump-macro-expansions顯示巨集產生了private var _page: SwiftUICore.State<StickerPage>與一個@storageRestrictions(initializes: _page) init(initialValue)存取器。xcrun devicectl --version:642.16;devicectl list devices --json-output寫出"jsonVersion": 5。27A266a 內 Icon Composer 的Info.plist:CFBundleShortVersionString為 27.0。 ↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩ -
Apple,App Store Connect release notes,擷取於 2026 年 9 月 15 日。2026 年 9 月 14 日的項目已在上表全文引用;2026 年 9 月 9 日的項目記錄了 RC SDK 上傳,並新增 iPhone Duo、iPhone 18 Pro Max、iPhone 18 Pro、Apple Watch Ultra 4 與 Apple Watch Series 12 的螢幕截圖與 App 預覽規格,並附註「Support for uploading assets for iPhone Duo in App Store Connect will be available later this year.」(App Store Connect 對 iPhone Duo 素材上傳的支援將於今年稍後推出。) ↩↩↩↩↩
-
Apple,iOS & iPadOS 27 Release Notes,SwiftUI 的 New Features(105893279),擷取於 2026 年 9 月 15 日。以下引文的出處:「Xcode 27 introduces a new
@Stateimplementation that avoids this repeated evaluation. This new behavior back-deploys to iOS 17 aligned OSes. The new@Stateis implemented with a Swift macro. It is largely source compatible with the property wrapper version, with a few exceptions.」;「If you provide an initial value at@Statedeclaration, and also try to assign a value to it in an initializer, the initializer value is discarded. This behavior has not changed because of the macro, but some such cases no longer compile:」及其StickerPageView程式碼清單;「When all stored members of a struct are private, the compiler synthesizes a private init that can be used in an extension of the same type:」及其程式碼清單;以及「The state macro disables this synthesized initializer. So the code above no longer compiles. To mitigate, assign value to members explicitly:」;另有兩個沒有程式碼清單的例外,「In rare situations, the automatic inference of generic arguments of@Stateis less flexible with the macro implementation. Write the type with more specificity.」與「Composing@Statewith other property wrappers or macros is not supported.」。同一份文件的 UIKit 一節載有第 6 步引用的兩項規定:New Features 的「iOS and iPadOS apps built with the 27.0 SDK or later are required to include a launch screen.」(168247372),以及 Deprecations 的「Apps built with the latest SDK must adopt the scene-based life cycle or they fail to launch.」(141837548)。 ↩↩↩↩↩↩↩↩↩↩ -
Cal Stephens,SE-0508: Array expression trailing closures,Swift Evolution,狀態為「Implemented (Swift 6.4)」,實作為 swiftlang/swift#86244,擷取於 2026 年 9 月 15 日。「Init accessors」小節是以下引文的出處:「One other case where this can result in an error is for properties with both an
initaccessor and initial value that is either an array or dictionary literal. If the getter is declared before theinitaccessor, we will now attempt to parse as a trailing closure:」、前文引用的消歧義那句話,以及「This particular case appears to be quite rare in practice, it does not appear in the source compatibility suite, or for internal Swift projects at Apple.」 ↩ -
Apple,Xcode 15 Release Notes,Linking 的 New Features(108915312),擷取於 2026 年 9 月 15 日:「The classic linker can still be explicitly requested using -ld64, and will be removed in a future release.」(仍可透過 -ld64 明確要求使用傳統連結器,該連結器將在未來版本中移除。) ↩↩