Introspect allows you to get the underlying UIKit or AppKit element of a SwiftUI view.
For instance, with Introspect you can access
UITableView to modify separators, or
UINavigationController to customize the tab bar.
How SwiftUI Introspect works
Introspect works by adding a custom
IntrospectionView to the view hierarchy, then looking into the UIKit hierarchy to find the relevant view.
For instance, when introspecting a
TextField, it will:
IntrospectionViewas an overlay of
- Get the view host of the introspection view (which is alongside the view host of the
- Get the previous sibling containing
Please note that this introspection method might break in future SwiftUI releases. Future implementations might not use the same hierarchy, or might not use UIKit elements that are being looked for. Though the library is unlikely to crash, the
.introspect() method will not be called in those cases.
Usage in production
Introspect is meant to be used in production. It does not use any private API. It only inspects the view hierarchy using publicly available methods. The library takes a defensive approach to inspecting the view hierarchy: there is no hard assumption that elements are laid out a certain way, there is no force-cast to UIKit classes, and the
introspect() methods are simply ignored if UIKit views cannot be found.
Mobile App Development Best Practices – 26.01
iOS ChatGPT in an iOS Shortcut — Worlds Smartest HomeKit Voice Assistant Multi-select Filter in Swift Prevent copy & paste...
Exploring the DoorDash app internal API
Analyzing the DoorDash Android app and its internal API. Main takeaways – Multiple fraud detection APIs, float vs. cents for...
Google changes Android policies in India
Google said it would continue to challenge the rulings from the Competition Commission of India. But he will continue to...
SwiftUI Navigation – Tools for making SwiftUI navigation simpler
Tools for making SwiftUI navigation simpler, more ergonomic and more precise.
Flutter Forward Videos
Preview some of our investments in the technologies of the future at Flutter Forward, streaming live from Nairobi, Kenya on...
Mobile App Development Best Practices – 25.01
iOS Slice that Collection: A Swift guide New Scanning and Text Capabilities with VisionKit How To Speed Up Swift By...