{ "$schema": "https://raw.githubusercontent.com/guitaripod/wwdc-sessions/master/schema/session.schema.json", "schemaVersion": 1, "id": "wwdc2026-262", "event": "wwdc2026", "eventName": "WWDC26", "year": 2026, "eventContentId": 262, "title": "What’s new in Swift", "description": "Join us for an update on Swift. Discover the latest language advancements, including updates for everyday ergonomics, improved concurrency, and safer high-performance code. Explore workflow and language interoperability improvements and updates in embedded Swift.", "url": "https://developer.apple.com/videos/play/wwdc2026/262", "sosumiURL": "https://sosumi.ai/videos/play/wwdc2026/262", "type": "Video", "publishedAt": "2026-06-08T14:00:00-07:00", "platforms": [ "iOS", "iPadOS", "macOS", "tvOS", "visionOS", "watchOS" ], "keywords": [], "topics": [ "Developer Tools", "Swift" ], "primaryTopic": "Swift", "duration": 1965, "hasTranscript": true, "transcriptWordCount": 5593, "availableLanguages": [ "eng", "fra", "jpn", "kor", "por", "spa", "zho" ], "media": { "hls": "https://devstreaming-cdn.apple.com/videos/wwdc/2026/262/5/d430e425-34fc-4ed5-b590-507ac593453a/cmaf.m3u8", "downloadHLS": "https://devstreaming-cdn.apple.com/videos/wwdc/2026/262/5/d430e425-34fc-4ed5-b590-507ac593453a/cmaf-download.m3u8", "downloadSD": "https://devstreaming-cdn.apple.com/videos/wwdc/2026/262/5/d430e425-34fc-4ed5-b590-507ac593453a/downloads/wwdc2026-262_sd.mp4", "downloadHD": "https://devstreaming-cdn.apple.com/videos/wwdc/2026/262/5/d430e425-34fc-4ed5-b590-507ac593453a/downloads/wwdc2026-262_hd.mp4", "duration": 1965 }, "codeSnippets": [ { "title": "Better Swift Concurrency diagnostics (catching in the task)", "language": "swift", "startTimeSeconds": 72, "code": "Task {\n do {\n try lander.fly(to: moon)\n }\n catch {\n lander.abort()\n }\n}" }, { "title": "Better Swift Concurrency diagnostics (saving the task for later)", "language": "swift", "startTimeSeconds": 81, "code": "let landingTask = Task {\n try lander.fly(to: moon)\n}\n\ndefer {\n await orbiter.rendezvous(with: lander)\n}\n\ntry await orbiter.justHangOut(waitingFor: landingTask)" }, { "title": "Better 'Sendable' conformances", "language": "swift", "startTimeSeconds": 87, "code": "final class Spacecraft: Sendable {\n ...\n weak let dockedAt: SpaceStation?\n ...\n}\n\nclass Mission: ~Sendable { ... }\n\nclass CrewedMission: Mission, @unchecked Sendable { ... }" }, { "title": "More accessible memberwise initializers", "language": "swift", "startTimeSeconds": 108, "code": "struct Briefing {\n internal var topic: String\n internal var scheduledAt: Date\n private var attendees: [Person] = []\n}\n\n// Generated memberwise initializers:\n// extension Briefing {\n// private init(topic: String, scheduledAt: Date, attendees: [Person] = []) { \n// self.topic = topic\n// self.scheduledAt = scheduledAt\n// self.attendees = attendees\n// }\n// \n// internal init(topic: String, scheduledAt: Date) {\n// self.topic = topic\n// self.scheduledAt = scheduledAt\n// self.attendees = []\n// }\n// }" }, { "title": "'anyAppleOS' availability (before)", "language": "swift", "startTimeSeconds": 123, "code": "extension Mission {\n @available(macOS 27, iOS 27, watchOS 27, tvOS 27, visionOS 27, *)\n func showStatus() { ... }\n\n @available(macOS 27, iOS 27, watchOS 27, visionOS 27, *)\n @available(tvOS, unavailable)\n func launch() { ... }\n\n #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS)\n func makeLiveActivityWidget() -> some Widget { ... }\n #endif\n}" }, { "title": "'anyAppleOS' availability (after)", "language": "swift", "startTimeSeconds": 137, "code": "extension Mission {\n @available(anyAppleOS 27, *)\n func showStatus() { ... }\n\n @available(anyAppleOS 27, *)\n @available(tvOS, unavailable)\n func launch() { ... }\n\n #if os(anyAppleOS)\n func makeLiveActivityWidget() -> some Widget { ... }\n #endif\n}" }, { "title": "Controlling warnings with '@diagnose'", "language": "swift", "startTimeSeconds": 160, "code": "@diagnose(DeprecatedDeclaration, as: ignored, reason: \"Flying with surplus hardware\")\nfunc makeApolloSoyuzMission() -> Mission {\n CrewedMission(\n rocket: makeSaturnIRocket(),\n payload: makeApolloCSM(),\n crew: [.daniellePoole, .nathanMorrison]\n )\n}\n\n@diagnose(StrictMemorySafety, as: warning)\nfunc uplinkCommand(from receiver: inout Receiver, to computer: inout Computer) {\n let commandSize = receiver.receiveInt()\n receiver.withReceivedData(byteCount: commandSize) {\n computer.receiveUplinkedCommand($0)\n }\n}\n\n@diagnose(ErrorInFutureSwiftVersion, as: error)\nfunc fetchPosition() -> (x: Double, y: Double, z: Double) {\n return self.rotation\n}" }, { "title": "Clarifying code with module selectors", "language": "swift", "startTimeSeconds": 227, "code": "import Rocket\nimport GiftShopToys\n\nlet rocket1 = SaturnV() // could mean `Rocket::SaturnV` or `GiftShopToys::SaturnV`\nlet rocket2 = Rocket.SaturnV() // prefers `Rocket::Rocket.SaturnV`\nlet rocket3 = Rocket::SaturnV() // correctly finds `Rocket::SaturnV`" }, { "title": "Clarifying code with module selectors (module selectors work on members, too)", "language": "swift", "startTimeSeconds": 300, "code": "//\n// Module Chemistry\n//\n\npublic protocol Flammable { ... }\n\nextension Flammable {\n /// Set `self` on fire.\n public func fire() { ... }\n}\n\n//\n// Module HumanResources\n//\n\nimport Chemistry\n\npublic protocol Employee { ... }\n\nextension Employee {\n /// Remove `self` from job.\n public func fire() { ... }\n}\n\npublic class LaunchPadTechnician: Employee, Flammable { ... }\n\n//\n// Module main\n//\n\nimport HumanResources\nimport Chemistry\n\nlet launchPadTechnician = LaunchPadTechnician(...)\n\nlaunchPadTechnician.HumanResources::fire()" }, { "title": "Task cancellation", "language": "swift", "startTimeSeconds": 386, "code": "// Radio for help\n\nextension Radio {\n func send(_ data: [UInt8] {\n if Task.isCancelled { return }\n // ...\n }\n}\n\nextension EmergencyTransponder {\n func sendSOS() {\n radio.send(makeSOSPacket())\n }\n}" }, { "title": "Task cancellation shield", "language": "swift", "startTimeSeconds": 400, "code": "// Radio for help\n\nextension Radio {\n func send(_ data: [UInt8] {\n if Task.isCancelled { return }\n // ...\n }\n}\n\nextension EmergencyTransponder {\n func sendSOS() {\n withTaskCancellationShield {\n \tradio.send(makeSOSPacket())\n }\n }\n}" }, { "title": "Constructing a new dictionary", "language": "swift", "startTimeSeconds": 413, "code": "// Map values with keys\n\nfunc makeCalendarDisplayNames(for missions: [Mission: LaunchWindow]) -> [Mission: String] {\n let new: [Mission: String] = .init(\n uniqueKeysWithValues: missions.lazy.map { mission, launchWindow in\n (mission, makeDisplayName(for: mission, in: launchWindow))\n }\n )\n return new\n}" }, { "title": "Dictionary.mapKeyedValues", "language": "swift", "startTimeSeconds": 426, "code": "// Map values with keys\n\nfunc makeCalendarDisplayNames(for missions: [Mission: LaunchWindow]) -> [Mission: String] {\n missions.mapKeyedValues { mission, launchWindow in\n makeDisplayName(for: mission, in: launchWindow)\n }\n}" }, { "title": "The new FilePath type", "language": "swift", "startTimeSeconds": 434, "code": "// FilePath handling macOS-named resources\n\nvar path: FilePath = \"/var/www/static\"\npath.components.append(\"WWDC\")\nprint(path.components)\n// [ \"var\", \"www\", \"static\", \"WWDC\" ]\n\nvar path: FilePath = \"/var/www/static/..namedresource/rsrc\"\nprint(path.components)\n// [ \"var\", \"www\", \"static\" ]" }, { "title": "Issue Severity", "language": "swift", "startTimeSeconds": 461, "code": "// Issue severity\n\n@Test(arguments: allRockets)\nfunc testBurn(rocket: Rocket) throws {\n rocket.burn(for: .seconds(150))\n let remaining = rocket.propellantKg / rocket.totalPropellantKg\n\n if remaining < 0.10 {\n Issue.record(\n \"\\(rocket.name) remaining fuel is below 10% reserve target\",\n severity: .warning\n )\n }\n\n #expect(remaining > 0.02, \"\\(rocket.name) propellant critically low - abort\")\n}" }, { "title": "Test Cancellation", "language": "swift", "startTimeSeconds": 472, "code": "// Test Cancellation\n\n@Test(arguments: allRockets)\nfunc testBurn(rocket: Rocket) throws {\n // solid-fuel rocket engines can't be stopped\n if rocket.engineType == .solid {\n try Test.cancel(\"\\(rocket.name) has solid fuel\")\n }\n\n rocket.burn(for: .seconds(150))\n let remaining = rocket.propellantKg / rocket.totalPropellantKg\n\n if remaining < 0.10 {\n Issue.record(\n \"\\(rocket.name) remaining fuel is below 10% reserve target\",\n severity: .warning\n )\n }\n\n #expect(remaining > 0.02, \"\\(rocket.name) propellant critically low - abort\")\n}" }, { "title": "XCTest interoperability: Using XCTest from Swift Testing", "language": "swift", "startTimeSeconds": 514, "code": "// XCTest interoperability: Using XCTest from Swift Testing\n\nfunc checkedTransmitAndReceive(on radio: Radio,\n packet: Packet,\n expectedByteCount: Int) throws -> [UInt8] {\n try radio.transmit(bytes: packet.data)\n let bytes = try radio.receive()\n XCTAssertEqual(bytes.count, expectedByteCount)\n return bytes\n}\n\n@Test\nfunc pingTest() throws {\n let radio = Radio()\n let bytes = try checkedTransmitAndReceive(on: radio, packet: .ping, expectedByteCount: 8)\n #expect(bytes == [0x00, 0x00, 0xf0, 0x37, 0x0f, 0xc7, 0x00, 0x01])\n}" }, { "title": "XCTest interoperability: Using Swift Testing from XCTest", "language": "swift", "startTimeSeconds": 528, "code": "// XCTest interoperability: Using Swift Testing from XCTest\n\nclass RadioTests: XCTestCase {\n func testPingPacketTransmission() {\n let radio = Radio()\n let bytes = try checkedTransmitAndReceive(on: radio,\n packet: .ping,\n expectedByteCount: 8)\n\n #expect(bytes == [0x00, 0x00, 0xf0, 0x36, 0x0f, 0xc7, 0x00, 0x02])\n }\n}" }, { "title": "Subprocess Output Stream", "language": "swift", "startTimeSeconds": 601, "code": "// Subprocess output streaming\n\nlet result = try await Subprocess.run(.name(\"ls\"),\n input: .none,\n output: .sequence,\n error: .string(limit:4096)) { execution in\n\t\texecution.standardOtput.strings().filter { $0.hasSuffix(\".obj\") }\n}\n\nfor try await objectFiles in result.closureOutput {\n \tprint(\"Object file: \\(objectFile)\")\n}" }, { "title": "Progress Manager - Concurrency", "language": "swift", "startTimeSeconds": 637, "code": "// Progress reporting - Concurrency\n\nlet manager = ProgressManager(totalCount: 100)\ntry await rocket.launch(mission.subprogress(assigningCount: 100))\n\nextension Rocket {\n func launch(_ progress: consuming Subprogress? = nil) async throws {\n let stage = progress?.start(totalCount: 3)\n try await ignite(); stage?.complete(count: 1)\n try await liftoff(); stage?.complete(count: 1)\n try await stageSeparation(); stage?.complete(count: 1)\n }\n}" }, { "title": "Progress Manager - progress reporting", "language": "swift", "startTimeSeconds": 637, "code": "// Progress reporting - progress reporting\n\nlet manager = ProgressManager(totalCount: 100)\ntry await rocket.launch(mission.subprogress(assigningCount: 100))\n\nTask {\n for await update in Observations({ mission.fractionCompleted }) {\n print(\"πŸš€ Mission \\(Int(update * 100))%\")\n }\n}" }, { "title": "Progress reporting - metadata", "language": "swift", "startTimeSeconds": 637, "code": "// Progress reporting - metadata\n\nextension Rocket {\n func ascend(_ progress: consuming Subprogress) async throws {\n let stage = progress.start(totalCount: 3)\n stage.detlaV = 3_400; try await burn(); stage.complete(count: 1)\n stage.detlaV = 2_100; try await stageSeparation(); stage.complete(count: 1)\n stage.detlaV = 1_800; try await coast(); stage.complete(count: 1)\n }\n}\n\nprint(\"Ξ”v to orbit: \\(mission.summary(of: \\.deltaV)) m/s\")" }, { "title": "Directly control inlining (source code)", "language": "swift", "startTimeSeconds": 1256, "code": "func histogram(of values: Values) -> [256 of Int] where Values: Sequence {\n var result = makeInts(randomized: false)\n\n for value in values {\n result[Int(value)] += 1\n }\n\n return result\n}\n\nfunc makeInts(randomized: Bool) -> [256 of Int] {\n if randomized {\n InlineArray { _ in Int.random(in: (.min)...(.max)) }\n } else {\n InlineArray(repeating: 0)\n }\n}" }, { "title": "Directly control inlining (inlined, but not optimized)", "language": "swift", "startTimeSeconds": 1261, "code": "func histogram(of values: Values) -> [256 of Int] where Values: Sequence {\n var result = if false { //\n InlineArray { _ in Int.random(in: (.min)...(.max)) } //\n } else { // Inlined code\n InlineArray(repeating: 0) //\n } //\n\n for value in values {\n result[Int(value)] += 1\n }\n return result\n}\n\nfunc makeInts(randomized: Bool) -> [256 of Int] {\n if randomized {\n InlineArray { _ in Int.random(in: (.min)...(.max)) }\n } else {\n InlineArray(repeating: 0)\n }\n}" }, { "title": "Directly control inlining (inlined and optimized)", "language": "swift", "startTimeSeconds": 1267, "code": "func histogram(of values: Values) -> [256 of Int] where Values: Sequence {\n var result = InlineArray(repeating: 0) // Inlined and optimized code\n\n for value in values {\n result[Int(value)] += 1\n }\n return result\n}\n\nfunc makeInts(randomized: Bool) -> [256 of Int] {\n if randomized {\n InlineArray { _ in Int.random(in: (.min)...(.max)) }\n } else {\n InlineArray(repeating: 0)\n }\n}" }, { "title": "Directly control inlining (preventing inlining)", "language": "swift", "startTimeSeconds": 1290, "code": "@inline(never)\nfunc makeInts(randomized: Bool) -> [256 of Int] {\n if randomized {\n InlineArray { _ in Int.random(in: (.min)...(.max)) }\n } else {\n InlineArray(repeating: 0)\n }\n}" }, { "title": "Directly control inlining (forcing inlining)", "language": "swift", "startTimeSeconds": 1299, "code": "@inline(always)\nfunc makeInts(randomized: Bool) -> [256 of Int] {\n if randomized {\n InlineArray { _ in Int.random(in: (.min)...(.max)) }\n } else {\n InlineArray(repeating: 0)\n }\n}" }, { "title": "Making generic functions faster with '@specialized'​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​", "language": "swift", "startTimeSeconds": 1315, "code": "func histogram(of values: Values) -> [256 of Int] where Values: Sequence {\n var result = makeInts(randomized: false)\n\n for value in values {\n result[Int(value)] += 1\n }\n\n return result\n}\n\n// Note: Specialized function doesn't actually have a directly callable name.\nfunc `histogram of [UInt8]`(of values: [UInt8]) -> [256 of Int] { //\n var result = makeInts(randomized: false) //\n //\n for value in values { //\n result[Int(value)] += 1 // Specialized code\n } //\n //\n return result //\n} //" }, { "title": "Making generic functions faster with '@specialized'​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​ (explicitly requesting specialization)", "language": "swift", "startTimeSeconds": 1337, "code": "@specialized(where Values == [UInt8])\nfunc histogram(of values: Values) -> [256 of Int] where Values: Sequence {\n var result = makeInts(randomized: false)\n\n for value in values {\n result[Int(value)] += 1\n }\n\n return result\n}\n\n// Note: Specialized function doesn't actually have a directly callable name.\nfunc `histogram of [UInt8]`(of values: [UInt8]) -> [256 of Int] { //\n var result = makeInts(randomized: false) //\n //\n for value in values { //\n result[Int(value)] += 1 // Specialized code\n } //\n //\n return result //\n} //" }, { "title": "Associated types can be '~Copyable' and '~Escapable'", "language": "swift", "startTimeSeconds": 1546, "code": "protocol Iterable: ~Copyable, ~Escapable {\n associatedtype Element: ~Copyable\n associatedtype IterableIterator: IterableIteratorProtocol, ~Copyable, ~Escapable\n associatedtype Failure: Error = Never\n\n func makeIterableIterator() -> IterableIterator\n\n var underestimatedCount: Int { get }\n}\n\nprotocol IterableIteratorProtocol: ~Copyable, ~Escapable {\n associatedtype Element: ~Copyable\n associatedtype Failure: Error = Never\n\n mutating func nextSpan(maximumCount: Int) throws(Failure) -> Span\n\n mutating func skip(by maximumOffset: Int) throws(Failure) -> Int\n}" }, { "title": "The problem with existing accessors", "language": "swift", "startTimeSeconds": 1648, "code": "@safe public struct UniqueBox: ~Copyable {\n private let valuePointer: UnsafeMutablePointer\n\n public init(_ value: consuming Value) {\n valuePointer = UnsafeMutablePointer.allocate(capacity: 1)\n valuePointer.initialize(to: value)\n }\n\n public var value: Value {\n get { valuePointer.pointee }\n set { valuePointer.pointee = newValue }\n }\n\n deinit {\n valuePointer.deinitialize(count: 1)\n valuePointer.deallocate()\n }\n}" }, { "title": "'borrow' and 'mutate' accessors", "language": "swift", "startTimeSeconds": 1699, "code": "@safe public struct UniqueBox: ~Copyable {\n private let valuePointer: UnsafeMutablePointer\n\n public init(_ value: consuming Value) {\n valuePointer = UnsafeMutablePointer.allocate(capacity: 1)\n valuePointer.initialize(to: value)\n }\n\n public var value: Value {\n borrow { valuePointer.pointee }\n mutate { &valuePointer.pointee }\n }\n\n deinit {\n valuePointer.deinitialize(count: 1)\n valuePointer.deallocate()\n }\n}" }, { "title": "Using 'MutableRef' to eliminate repeated accesses (with un-hoisted access)", "language": "swift", "startTimeSeconds": 1814, "code": "func updateCount(\n for key: Key,\n from sets: [Set],\n in counts: inout [Key: Int]\n) {\n for set in sets {\n if set.contains(key) {\n counts[key, default: 0] += 1\n }\n }\n}" }, { "title": "Using 'MutableRef' to eliminate repeated accesses (hoisted by 'inout' parameter)", "language": "swift", "startTimeSeconds": 1834, "code": "func updateCount(\n for key: Key,\n from sets: [Set],\n in counts: inout [Key: Int]\n) {\n func updateCountImpl(count: inout Int) {\n for set in sets {\n if set.contains(key) {\n count += 1\n }\n }\n }\n\n updateCountImpl(count: &counts[key, default: 0])\n}" }, { "title": "Using 'MutableRef' to eliminate repeated accesses (hoisted by 'MutableRef')", "language": "swift", "startTimeSeconds": 1841, "code": "func updateCount(\n for key: Key,\n from sets: [Set],\n in counts: inout [Key: Int]\n) {\n var countRef = MutableRef(&counts[key, default: 0])\n\n for set in sets {\n if set.contains(key) {\n countRef.value += 1\n }\n }\n}" } ], "resources": [ { "title": "Swift Blog", "url": "https://www.swift.org/blog/", "type": "documentation", "description": "The Swift.org blog" }, { "title": "Explore documentation on swift.org", "url": "https://www.swift.org/documentation/", "type": "documentation", "description": null }, { "title": "Swift Forums", "url": "https://forums.swift.org", "type": "developerForum", "description": "Forums for the Swift open-source project." } ], "path": "sessions/wwdc2026/262-what-s-new-in-swift/", "files": { "metadata": "sessions/wwdc2026/262-what-s-new-in-swift/metadata.json", "readme": "sessions/wwdc2026/262-what-s-new-in-swift/README.md", "transcript": "sessions/wwdc2026/262-what-s-new-in-swift/transcript.md", "transcriptJSON": "sessions/wwdc2026/262-what-s-new-in-swift/transcript.json" } }