Home / Companies / Sentry / Blog / Post Details
Content Deep Dive

"Swizzling" iOS functions in Swift

Blog post from Sentry

Post Details
Company
Date Published
Author
Noah Martin
Word Count
1,414
Company Posts That Month
13
Language
English
Hacker News Points
-
Post removed?
No
Summary

SwiftUI view performance is often impacted by the speed and frequency of calls to the body property, and while tools like Sentry can monitor UIKit performance through method swizzling, SwiftUI lacks this capability due to its pure Swift nature. A new technique, discussed in the text, involves using the ViewPerformance Swift package to address this limitation for debug builds by identifying all views and their body accessors at runtime, then installing hooks on each function using a combination of protocol conformance descriptors and software breakpoints. This approach leverages Swift's runtime metadata to achieve functionality similar to Objective-C swizzling, enabling developers to monitor SwiftUI view performance without modifying the executable in production, although its use is restricted to debug environments due to Apple's restrictions. The package is open-source and encourages community contributions to explore further use cases, while for production environments, the Sentry SDK remains an option for tracking view performance.

Trends Found in this Post
Trend Post Mentions Total Month Mentions Posts Companies MoM
Observability 1 2,104 424 141 -21%
Use This Data

Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.