Streaming is available in most browsers,
and in the Developer app.
-
What’s new in Swift
Join us for an update on Swift. We'll briefly go through a history of Swift over the past decade, and show you how the community has grown through workgroups, expanded the package ecosystem, and increased platform support. We'll introduce you to a new language mode that achieves data-race safety by default, and a language subset that lets you run Swift on highly constrained systems. We'll also explore some language updates including noncopyable types, typed throws, and improved C++ interoperability.
Chapters
- 0:00 - Introduction
- 0:12 - Swift over the years
- 3:44 - Agenda
- 3:58 - Swift project update
- 4:08 - Community
- 4:59 - Packages
- 5:50 - Blogs
- 6:33 - Swift everywhere
- 7:37 - Cross compilation to Linux
- 11:27 - Foundation
- 13:06 - Swift Testing
- 14:34 - Improvements to builds
- 16:15 - Swift's new space
- 17:03 - Language updates
- 17:29 - Noncopyable types
- 19:55 - Embedded Swift
- 21:47 - C++ interoperability
- 23:34 - Typed throws
- 26:07 - Swift 6 language mode and data-race safety
- 28:43 - Low-level synchronization primitives
- 29:59 - Wrap up
Resources
- Forum: Programming Languages
- Install Swift
- Swift 6 Migration Guide
- Swift Blog
- Swift Community Overview
- Swift Forums
- The Swift Programming Language
Related Videos
WWDC24
- Consume noncopyable types in Swift
- Demystify explicitly built modules
- Explore Swift performance
- Go further with Swift Testing
- Go small with Embedded Swift
- Meet Swift Testing
- Migrate your app to Swift 6
WWDC23
-
DownloadArray
-
-
9:15 - Swift Build
swift build
-
9:20 - Inspecting the build output
file .build/debug/CatService
-
9:24 - Run the REST API service
.build/debug/CatService
-
9:30 - Make a request to REST API service
curl localhost:8080/api/emoji
-
9:45 - Install the Fully static Linux SDK for Swift
swift sdk install ~/preview-static-swift-linux-0.0.1.tar.gz
-
10:18 - Swift build command flag to cross compile
swift build --swift-sdk aarch64-swift-linux-musl
-
10:30 - Inspecting the build output
file .build/debug/CatService
-
10:35 - Copy the service over to our Linux server and run it
scp .build/debug/CatService demo-linux-host:~/CatService ./CatService
-
10:45 - Make a request to REST API service from macOS to Linux
curl demo-linux-host:8080/api/emoji
-
13:50 - Swift Testing - Declare a test function
// Swift Testing import Testing @Test func rating() { let video = Video(id: 2, name: "Mystery Creek") #expect(video.rating == "⭐️⭐️⭐️⭐️") }
-
13:55 - Swift Testing - Customize a test’s name
// Swift Testing import Testing @Test("Recognized rating") func rating() { let video = Video(id: 2, name: "Mystery Creek") #expect(video.rating == "⭐️⭐️⭐️⭐️") }
-
14:13 - Swift Testing - Organize test function with tags
// Swift Testing import Testing @Test("Recognized rating", .tags(.critical)) func rating() { let video = Video(id: 2, name: "Mystery Creek") #expect(video.rating == "⭐️⭐️⭐️⭐️") }
-
14:19 - Swift Testing - Parameterize test with arguments
// Swift Testing import Testing @Test("Recognized rating", .tags(.critical), arguments: [ (1, "A Beach", "⭐️⭐️⭐️⭐️⭐️"), (2, "Mystery Creek", "⭐️⭐️⭐️⭐️"), ]) func rating(videoId: Int, videoName: String, expectedRating: String) { let video = Video(id: videoId, name: videoName) #expect(video.rating == expectedRating) }
-
17:50 - Noncopyable types
struct File: ~Copyable { private let fd: CInt init(descriptor: CInt) { self.fd = descriptor } func write(buffer: [UInt8]) { // ... } deinit { close(fd) } }
-
18:12 - Noncopyable types
guard let fd = open(name) else { return } let file = File(descriptor: fd) file.write(buffer: data)
-
18:42 - Noncopyable types
struct File: ~Copyable { private let fd: CInt init?(name: String) { guard let fd = open(name) else { return nil } self.fd = fd } func write(buffer: [UInt8]) { // ... } deinit { close(fd) } }
-
22:29 - C++ Interoperability
struct Person { Person(const Person&) = delete; Person(Person &&) = default; // ... };
-
22:34 - C++ Interoperability
struct Developer: ~Copyable { let person: Person init(person: consuming Person) { self.person = person } } let person = Person() let developer = Developer(person: person)
-
22:40 - C++ Interoperability
struct Developer: ~Copyable { let person: Person init(person: consuming Person) { self.person = person } } let person = Person() let developer = Developer(person: person) person.printInfo()
-
23:43 - Untyped throws
enum IntegerParseError: Error { case nonDigitCharacter(String, index: String.Index) } func parse(string: String) throws -> Int { for index in string.indices { // ... throw IntegerParseError.nonDigitCharacter(string, index: index) } } do { let value = try parse(string: "1+234") } catch let error as IntegerParseError { // ... } catch { // error is 'any Error' }
-
24:19 - Typed throws
enum IntegerParseError: Error { case nonDigitCharacter(String, index: String.Index) } func parse(string: String) throws(IntegerParseError) -> Int { for index in string.indices { // ... throw IntegerParseError.nonDigitCharacter(string, index: index) } } do { let value = try parse(string: "1+234") } catch { // error is 'IntegerParseError' }
-
24:39 - Typed throws - any and Never error types
func parse(string: String) throws -> Int { //... } func parse(string: String) throws(any Error) -> Int { //... } func parse(string: String) -> Int { //... } func parse(string: String) throws(Never) -> Int { //... }
-
28:02 - Passing a NonSendable reference across actor isolation boundaries
class Client { init(name: String, balance: Double) {} } actor ClientStore { static let shared = ClientStore() private var clients: [Client] = [] func addClient(_ client: Client) { clients.append(client) } } @MainActor func openAccount(name: String, balance: Double) async { let client = Client(name: name, balance: balance) await ClientStore.shared.addClient(client) }
-
28:52 - Atomic
import Dispatch import Synchronization let counter = Atomic<Int>(0) DispatchQueue.concurrentPerform(iterations: 10) { _ in for _ in 0 ..< 1_000_000 { counter.wrappingAdd(1, ordering: .relaxed) } } print(counter.load(ordering: .relaxed))
-
29:21 - Mutex
import Synchronization final class LockingResourceManager: Sendable { let cache = Mutex<[String: Resource]>([:]) func save(_ resource: Resource, as key: String) { cache.withLock { $0[key] = resource } } }
-
-
Looking for something specific? Enter a topic above and jump straight to the good stuff.
An error occurred when submitting your query. Please check your Internet connection and try again.