Swift 6.3 and 6.4 introduce a range of language and library improvements including anyAppleOS availability shorthand, module selectors (::), task cancellation shielding, improved Swift Testing interoperability with XCTest, and new standard library APIs for dictionaries and filepaths.
β’ anyAppleOS availability syntax and the @diagnose attribute dramatically reduce boilerplate and give you surgical control over warnings without polluting the rest of your codebase
β’ Module selectors (Module::Type) solve long-standing ambiguity bugs in codebases that import multiple packages with overlapping API names
β’ Swift Testing now interoperates bidirectionally with XCTest, letting teams migrate incrementally without losing coverage
Demonstrates four key Swift 6.3/6.4 improvements: anyAppleOS availability, @diagnose for warning suppression, module selector disambiguation, and mapKeyedValues on Dictionary.
import Foundation
import Testing
// 1. anyAppleOS availability β replaces listing iOS/macOS/tvOS/watchOS/visionOS separately
@available(anyAppleOS 27, *)
func fetchUserProfile(id: String) async throws -> String {
// Simulated async fetch
try await Task.sleep(for: .milliseconds(100))
return "Profile(\(id))"
}
// 2. @diagnose β suppress a specific warning category in one place
// without affecting the rest of the project
struct LegacyBridge {
@diagnose(.ignore, "deprecated_declaration")
func callDeprecatedAPI() {
// Imagine this calls a deprecated API β warning is silenced only here
print("Using legacy path temporarily")
}
}
// 3. mapKeyedValues β dictionary transform with access to both key and value
let productPrices: [String: Double] = [
"apple": 1.20,
"banana": 0.50,
"cherry": 3.00
]
// Old way required constructing a new Dictionary by hand:
// var labeled: [String: String] = [:]
// for (key, value) in productPrices { labeled[key] = "\(key): $\(value)" }
// New mapKeyedValues passes both key AND value into the closure:
let labeledPrices: [String: String] = productPrices.mapKeyedValues { key, value in
"\(key.capitalized): $\(String(format: "%.2f", value))"
}
// 4. Task cancellation shield β perform cleanup even after task is cancelled
func writeDataSafely(data: Data, to url: URL) async throws {
let task = Task {
// Cancel the task immediately to simulate cancellation
}
task.cancel()
try await Task.withoutActuallyEscaping(data) { _ in } // illustrative
await Task.withCancellationShield {
// Inside here, isCancelled always returns false
// Safe to finish writing data to avoid file corruption
print("Completing write despite cancellation: \(data.count) bytes")
}
}
// 5. Swift Testing β dynamic test cancellation and warning-level issues
@Suite("Product Pricing Tests")
struct PricingTests {
@Test("Labeled prices are correctly formatted", arguments: ["apple", "banana", "cherry"])
func testLabeledPrice(product: String) async throws {
guard productPrices[product] != nil else {
// Cancel just this argument instead of failing the whole suite
try await Test.current?.cancel()
return
}
let label = labeledPrices[product]!
#expect(label.hasPrefix(product.capitalized))
}
@Test("Prices are positive")
func testPositivePrices() {
for (key, value) in productPrices {
if value <= 0 {
// Warning-severity issue β won't block CI
Issue.record("\(key) has suspicious price \(value)", severity: .warning)
}
}
#expect(productPrices.values.allSatisfy { $0 > 0 })
}
}β’ anyAppleOS only collapses platforms where version numbers align; platform-specific carve-outs still need individual attributes β’ The @diagnose attribute suppresses warnings locally β overuse can hide real issues, use judiciously β’ XCTest β Swift Testing interop reports issues as warnings by default; opt into failures via Xcode build settings β’ Module selector syntax (::) is new and may confuse readers unfamiliar with Swift 6.3+
None β language and library changes apply across all supported platforms
More iOS 27 APIs land every week.
Get notified when new capabilities are published β no noise, just signal.