SwiftUI-Introspect banner

Open Source

SwiftUI-Introspect Overview

SwiftUI Introspect is an open-source library that allows you to get the underlying UIKit or AppKit element of a SwiftUI view. Created by Loïs Di Qual, it is a must have for SwiftUI projects.

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:
  • Add IntrospectionView as an overlay of TextField
  • Get the view host of the introspection view (which is alongside the view host of the UITextField)
  • Get the previous sibling containing UITextField

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.

Stay on top of new tools for iOS developers

Subscribe to get a convenient weekly roundup of iOS Dev Tools' newest addition
of helpful and time-saving developer tools, services, and SDKs to get your job done faster.