2026 SwiftDeveloper Tools
WWDC26 · 27 min · Swift / Developer Tools
Profile, fix, and verify: Improve app responsiveness with Instruments
Tackle app responsiveness issues with a clear workflow. Explore the Swift Concurrency instrument, Time Profiler, and System Trace to pinpoint bottlenecks. Discover how to use top functions and run comparisons to measure your improvements and confirm your fixes. And learn about other enhancements in Instruments which make each iteration of this cycle faster than ever, so you can deliver a smoother user experience in less time.
Watch at developer.apple.com ↗Chapters
Code shown on screen · 9 snippets
Add signpost interval around Lasso Selection
// Add signpost interval around Lasso Selection
import os.signpost
let signposter = OSSignposter(subsystem: “Demo App", category: .pointsOfInterest)
var lassoIntervalState: OSSignpostIntervalState? = nil
func lassoSelectionUpdated() {
lassoIntervalState = signposter.beginInterval("Lasso Selection")
// Update selection in canvas…
}
func lassoSelectionEnded() {
// Finalize lasso selection...
signposter.endInterval("Lasso Selection", lassoIntervalState!)
} Existentials
// Existentials
protocol Foo { }
struct TypeA: Foo { }
struct TypeB: Foo { }
func bar(_ foo: any Foo) {
} Concrete Types
// Concrete types
protocol Foo { }
struct TypeA: Foo { }
struct TypeB: Foo { }
func bar(_ a: TypeA) {
}
func bar(_ b: TypeB) {
} Concrete Types + Generics
// Concrete types
protocol Foo { }
struct TypeA: Foo { }
struct TypeB: Foo { }
func bar(_ a: TypeA) {
}
func bar(_ b: TypeB) {
}
// Generics
protocol Foo { }
struct TypeA: Foo { }
struct TypeB: Foo { }
func bar<T: Foo>(_ generic: T) {
} Concrete Types + Generics + Enums
// Concrete types
protocol Foo { }
struct TypeA: Foo { }
struct TypeB: Foo { }
func bar(_ a: TypeA) {
}
func bar(_ b: TypeB) {
}
// Generics
protocol Foo { }
struct TypeA: Foo { }
struct TypeB: Foo { }
func bar<T: Foo>(_ generic: T) {
}
// Enums
enum Foo {
case a(TypeA)
case b(TypeB)
}
struct TypeA { }
struct TypeB { }
func bar(_ enum: Foo) {
} Thumbnail Rendering
// Thumbnail rendering
let drawingData = note.drawingData
let canvasImages = note.decodeCanvas()
thumbnail = await Task(name: "Render Thumbnail") {
await renderThumbnail(drawingData: drawingData, canvasImages: canvasImages, size: CGSize(width: 300, height: 240))
}.value Thumbnail Rendering Off Main Actor
// Thumbnail rendering off Main Actor
let drawingData = note.drawingData
let canvasImages = note.decodeCanvas()
thumbnail = await Task(name: "Render Thumbnail") { in
await renderThumbnail(drawingData: drawingData, canvasImages: canvasImages, size: CGSize(width: 300, height: 240))
}.value File Saving
// File saving
let encoder = PropertyListEncoder()
encoder.outputFormat = .binary
guard let data = try? encoder.encode(snapshots) else { return }
let id = signposter.beginInterval("Writing To File")
try? data.write(to: fileURL, options: .atomic)
signposter.endInterval("Writing To File", id) File Saving off Main thread
// File saving
Task { in
let encoder = PropertyListEncoder()
encoder.outputFormat = .binary
guard let data = try? encoder.encode(snapshots) else { return }
let id = signposter.beginInterval("Writing To File")
try? data.write(to: fileURL, options: .atomic)
signposter.endInterval("Writing To File", id)
} Resources
Related sessions
-
27 min -
33 min -
28 min -
43 min -
28 min