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 ↗Chapters
- 0:00 — Introduction
- 0:29 — Updates in editing
- 0:33 — Code completion
- 1:01 — Adopting Swift 6 data-race safety guarantees
- 2:49 — Improvements to Previews
- 6:22 — Updates in builds
- 6:26 — Explicit modules
- 7:15 — Package resolution
- 8:30 — What's new in debugging
- 8:35 — Build process and debugging
- 9:07 — Thread performance checker
- 9:23 — The organizer
- 12:16 — The RealityKit debugger
- 12:55 — Meet Swift Testing
- 18:42 — What's new in Instruments
- 19:44 — Meet the flame graph
- 21:38 — Wrap up
Code shown on screen · 15 snippets
Inline State within Preview
#Preview {
var currentFace = RobotFace.heart
} View using Inline State
RobotFaceSelectorView(currentFace: $currentFace) Complete Preview using Previewable
#Preview {
var currentFace = RobotFace.heart
RobotFaceSelectorView(currentFace: $currentFace)
} Type Conforming to PreviewModifier
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
extension PreviewTrait where T == Preview.ViewTraits {
static var sampleNamer: Self = .modifier(SampleRobotNamer())
} Preview using created PreviewModifier
#Preview(traits: .sampleNamer) {
RobotNameSelectorView()
} AVPlayer Creation
struct BOTanistAVPlayer {
func player(url: URL) throws -> AVPlayer {
let player = AVPlayer(url: url)
return player
}
} AVPlayer Call Site
self.player = try? await robotVideoAVPlayer() AVPlayer Initialization
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
import Testing
@testable import BOTanist
// When using the default init Plant(type:) make sure the planting style is graft
func plantingRoses() {
// First create the two Plant structs
// Verify with #expect
} Complete Test
import Testing
@testable import BOTanist
// When using the default init Plant(type:) make sure the planting style is graft
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
extension Tag {
static var planting: Self
} Tag Usage in @Test
.tags(.planting) Slow Asset Loading
for asset in allAssets {
asset.load()
} Fast Asset Loading
await withDiscardingTaskGroup { group in
for asset in allAssets {
group.addTask {
asset.load()
}
}
} Resources
Related sessions
-
42 min -
15 min -
24 min -
29 min -
24 min -
27 min