Swift 6.3 and 6.4 introduce a range of language and library improvements including anyAppleOS availability syntax, module selectors for disambiguation, task cancellation shielding, improved Swift Testing interoperability with XCTest, and a new Foundation ProgressManager type.
• anyAppleOS availability syntax dramatically reduces boilerplate in multi-platform codebases, replacing four separate platform conditions with one
• Module selectors (::) solve long-standing ambiguity issues when two imported modules define identically-named types or methods
• Swift Testing enhancements (warning-severity issues, dynamic cancellation, XCTest interop) give teams a safe migration path away from XCTest without losing coverage
Demonstrates three key Swift 6.4 additions in one file: anyAppleOS availability, Task.withCancellationShield for safe cleanup, and mapKeyedValues on Dictionary.
import Foundation
import Swift
// MARK: - 1. anyAppleOS availability
// Before Swift 6.4 you needed:
// @available(iOS 18, macOS 15, watchOS 11, tvOS 18, visionOS 2, *)
// Now:
@available(anyAppleOS 26, *)
func fetchLatestManifest() async throws -> Data {
let url = URL(string: "https://example.com/manifest.json")!
let (data, _) = try await URLSession.shared.data(from: url)
return data
}
// MARK: - 2. Task Cancellation Shield
// Guarantees a critical write completes even if the parent task is cancelled.
func persistPendingChanges(records: [String]) async throws {
// Expensive network work here (respects cancellation) ...
try Task.checkCancellation()
// Shield ensures the flush to disk always finishes.
await Task.withCancellationShield {
for record in records {
// Simulate writing each record to disk
print("Writing record: \(record)")
}
print("All records persisted safely.")
}
}
// MARK: - 3. Dictionary.mapKeyedValues
// Old approach required building a new dictionary manually when the key was needed.
let inventory: [String: Int] = ["apple": 3, "banana": 7, "cherry": 1]
// New in Swift 6.4: both key and value are passed to the closure.
let discountedLabels: [String: String] = inventory.mapKeyedValues { key, value in
value > 5 ? "\(key.capitalized): SALE" : "\(key.capitalized): \(value) left"
}
// Expected output:
// ["Apple": "Apple: 3 left", "Banana": "Banana: SALE", "Cherry": "Cherry: 1 left"]
print(discountedLabels)
// MARK: - 4. @diagnose — suppress a deprecated-declaration warning locally
@diagnose(ignore: "deprecated_declaration")
func legacyEntryPoint() {
// Calls a deprecated API while migration is in progress.
// The warning is silenced only inside this function.
print("Using legacy path temporarily.")
}iOS 27 adds sectioned queries, codable model attributes, ResultsObserver for non-SwiftUI change observation, and HistoryObserver for reacting to persistent history changes in SwiftData.
USDKit is a new first-party Swift framework introduced in iOS/macOS 27 that brings native USD scene creation, composition, modification, and export capabilities to Apple platform apps, with deep RealityKit and Spatial Preview integration.
LiveCommunicationKit is the modern replacement for CXProvider that delivers rich, native conversation UIs integrated with the Lock Screen, Dynamic Island, Phone app Recents, and Siri. It provides a unified lifecycle model for audio and video conversations with a single delegate-driven action pipeline.
• anyAppleOS requires all targeted platform deployment targets to share the same version number; mismatched targets still need individual annotations • Module selector syntax (::) is new in Swift 6.3 — older toolchains will not compile it • XCTest↔Swift Testing interop issues are reported as warnings by default; opt in to failures in Xcode Build Settings • weak let for Sendable conformance only applies when the property is never reassigned after init
None — language and standard library improvements are available on all supported Swift platforms
The NowPlaying framework introduces a first-class Swift API for surfacing app media in system-wide now-playing surfaces — Lock Screen, Control Center, Dynamic Island, StandBy, CarPlay, Apple Watch, and Apple TV — via a declarative MediaSessionRepresentable protocol. It also supports remote media sessions (for controlling external speakers/TVs) and Media Sharing Extensions for routing media to third-party devices.