Dunfey · Hotel WWDC as data, est. 1983
Front desk everything
Years
Topics

2024 EssentialsSwiftSwiftUI & UI FrameworksDeveloper Tools

WWDC24 · 22 min · Essentials / Swift / SwiftUI & UI Frameworks / Developer Tools

What’s new in Xcode 16

Discover the latest productivity and performance improvements in Xcode 16. Learn about enhancements to code completion, diagnostics, and Xcode Previews. Find out more about updates in builds and explore improvements in debugging and Instruments.

Watch at developer.apple.com ↗

Transcript all transcripts

Chapters

Code shown on screen · 15 snippets

Inline State within Preview swift · at 3:37 ↗
#Preview {
    @Previewable @State var currentFace = RobotFace.heart
}
View using Inline State swift · at 3:45 ↗
RobotFaceSelectorView(currentFace: $currentFace)
Complete Preview using Previewable swift · at 3:53 ↗
#Preview {
    @Previewable @State var currentFace = RobotFace.heart
    
    RobotFaceSelectorView(currentFace: $currentFace)
}
Type Conforming to PreviewModifier swift · at 4:40 ↗
struct SampleRobotNamer: PreviewModifier {
    typealias Context = RobotNamer

    static func makeSharedContext() async throws -> Context {
        let url = URL(fileURLWithPath: "/tmp/local_names.txt")
        return try await RobotNamer(url: url)
    }
    
    func body(content: Content, context: Context) -> some View {
        content.environment(context)
    }
}
Extension on PreviewTrait swift · at 5:29 ↗
extension PreviewTrait where T == Preview.ViewTraits {
    @MainActor static var sampleNamer: Self = .modifier(SampleRobotNamer())
}
Preview using created PreviewModifier swift · at 5:38 ↗
#Preview(traits: .sampleNamer) {
    RobotNameSelectorView()
}
AVPlayer Creation swift · at 10:26 ↗
struct BOTanistAVPlayer {
    func player(url: URL) throws -> AVPlayer {
        let player = AVPlayer(url: url)

        return player
    }
}
AVPlayer Call Site swift · at 11:28 ↗
self.player = try? await robotVideoAVPlayer()
AVPlayer Initialization swift · at 11:57 ↗
private nonisolated func robotVideoAVPlayer() async throws -> AVPlayer? {
    guard let url = Bundle.main.url(forResource: RobotVideo.resource, withExtension: RobotVideo.ext) else {
        throw BOTanistAppError.videoNotFound(forResource: RobotVideo.resource, withExtension: RobotVideo.ext)
    }

    let avPlayer = BOTanistAVPlayer()
    let player = try avPlayer.player(url: url)

    return player
}
Initial Test Scaffolding swift · at 13:42 ↗
import Testing
@testable import BOTanist


// When using the default init Plant(type:) make sure the planting style is graft
@Test func plantingRoses() {
    // First create the two Plant structs
    

    // Verify with #expect
}
Complete Test swift · at 14:36 ↗
import Testing
@testable import BOTanist


// When using the default init Plant(type:) make sure the planting style is graft
@Test
func plantingRoses() {
    // First create the two Plant structs
    let plant = Plant(type: .rose)
    let expected = Plant(type: .rose, style: .graft)

    // Verify with #expect
    #expect(plant == expected)
}
Custom Tag swift · at 17:35 ↗
extension Tag {
    @Tag static var planting: Self
}
Tag Usage in @Test swift · at 17:42 ↗
.tags(.planting)
Slow Asset Loading swift · at 20:37 ↗
for asset in allAssets {
    asset.load()
}
Fast Asset Loading swift · at 20:54 ↗
await withDiscardingTaskGroup { group in
    for asset in allAssets {
        group.addTask {
            asset.load()
        }
    }
}

Resources