Sentry Jan 10, 2026

Swizzling SwiftUI View Body

Article Summary

Noah Martin from Sentry cracked a problem that seemed impossible: swizzling pure Swift code to automatically track SwiftUI view performance. The technique is wild.

UIKit apps get automatic performance tracing through Objective-C swizzling, but SwiftUI's pure Swift types don't support this. Martin details how Sentry's ViewPerformance package achieves similar functionality by parsing protocol conformance descriptors and using software breakpoints to hook into every SwiftUI view body.

Key Takeaways

Critical Insight

You can now automatically trace SwiftUI view performance in debug builds using protocol witness tables and breakpoints, bringing UIKit-style automatic instrumentation to pure Swift code.

The article reveals why this technique shares DNA with iOS app launch optimization and what limitation prevents tracking generic SwiftUI views.

Recent from Sentry

Related Articles