Repolode
siteline

siteline/swiftui-introspect

A Swift library that lets SwiftUI code access the underlying UIKit or AppKit view behind a SwiftUI view to customize it.

Stars
6,574
Forks
420
Open issues
16
Last commit
last month

What is it?

SwiftUI does not expose many properties of its underlying UIKit and AppKit components. SwiftUI Introspect fills that gap by adding invisible marker views around a SwiftUI view, then searching the view hierarchy between them for the matching UIKit or AppKit instance, such as a UIScrollView or NSTextField. Your closure receives that native view so you can change properties SwiftUI does not offer.

The library covers a broad set of controls, including List, ScrollView, Form, TextField, NavigationStack, TabView, Table, and sheets or popovers. Each introspection target requires an explicit platform version, such as .iOS(.v18), because underlying view types can change between OS releases. Range-based version predicates are available for library authors who want to support future versions.

The project states that it does not use private APIs and does not force-cast views; if the expected view is missing, the modifier is ignored. Its documentation advises using it sparingly, since native SwiftUI modifiers should be preferred when they exist.

Key features

  • 01Accesses the underlying UIKit or AppKit view of many SwiftUI controls.
  • 02Supports iOS, tvOS, visionOS and macOS platform targets.
  • 03Requires explicit OS version opt-in for each introspection target.
  • 04Offers range-based version predicates for future platform versions.
  • 05Lets developers define custom introspectable view types for unsupported elements.

Use cases

  • Changing the bounce behavior or background of a SwiftUI List or ScrollView.
  • Customizing the appearance of a TextField or SecureField beyond SwiftUI modifiers.
  • Styling the navigation bar of a NavigationStack or NavigationView.
  • Keeping a reference to a native UIKit view for advanced control in an iOS app.

Quick start

  1. 1

    Add the SwiftUIIntrospect package to your Swift Package Manager dependencies

    .package(url: "https://github.com/siteline/swiftui-introspect", from: "27.0.0"),
  2. 2

    Add the SwiftUIIntrospect product to your target dependencies

    .product(name: "SwiftUIIntrospect", package: "swiftui-introspect"),

Things to know

  • Introspection requires opting in to each OS version (for example .iOS(.v18)) because underlying UIKit/AppKit types can change between major versions.
  • Only the view types listed in the README are supported, and many SwiftUI views such as Text and Image cannot be introspected.

In collections

Topics

#swiftui#uikit#appkit#ios#macos#swift-package-manager#ui-customization#inspect#inspection#introspection

FAQ

What is swiftui-introspect?
A Swift library that lets SwiftUI code access the underlying UIKit or AppKit view behind a SwiftUI view to customize it. SwiftUI does not expose many properties of its underlying UIKit and AppKit components. SwiftUI Introspect fills that gap by adding invisible marker views around a SwiftUI view, then searching the view hierarchy between them for the matching UIKit or AppKit instance, such as a UIScrollView or NSTextField. Your closure receives that native view so you can change properties SwiftUI does not offer.
Is swiftui-introspect free to use? What license does it have?
swiftui-introspect is open source under the MIT license. Check the license terms before using it in commercial products.
Is swiftui-introspect still maintained?
Updated within 6 months. The last commit to swiftui-introspect was on Oct 7, 2026.
What can I use swiftui-introspect for?
Changing the bounce behavior or background of a SwiftUI List or ScrollView. Customizing the appearance of a TextField or SecureField beyond SwiftUI modifiers. Styling the navigation bar of a NavigationStack or NavigationView. Keeping a reference to a native UIKit view for advanced control in an iOS app.
How do I install swiftui-introspect?
Add the SwiftUIIntrospect package to your Swift Package Manager dependencies: .package(url: "https://github.com/siteline/swiftui-introspect", from: "27.0.0"), Add the SwiftUIIntrospect product to your target dependencies: .product(name: "SwiftUIIntrospect", package: "swiftui-introspect"),
Where can I get swiftui-introspect?
The source code and installation instructions are on GitHub: https://github.com/siteline/swiftui-introspect

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects