siteline/swiftui-introspect

Introspect underlying UIKit/AppKit components from SwiftUI

View on GitHub ↗Jump to charts ↓

Summary Information

Updated 49 minutes ago
Added to GitGenius on September 10th, 2026
Created on November 26th, 2019
Open Issues & Pull Requests: 16 (+0)
GitHub issues: Enabled
Number of forks: 417
Total Stargazers: 6,555 (+0)
Total Subscribers: 55 (+0)

Repository Insights (GitGenius)

Most active contributors

Sign in to see contributor activity.

Related repositories by overlapping contributors

No overlapping-contributor repos identified yet.

Charts & Analytics

Fetching additional details & charts...

Issue Activity (beta)

Issue API getrepoissuespagesummary failed: 429 Rate limit exceeded. Please try again later.

Detailed Description

SwiftUI Introspect is a library that lets you access the underlying UIKit or AppKit view for a SwiftUI view.

SwiftUI provides a declarative interface that abstracts away the underlying platform views, but sometimes you need direct access to UIKit or AppKit components to apply customizations or behaviors that SwiftUI does not expose. SwiftUI Introspect solves this by adding invisible marker views above and below your target SwiftUI view, then traversing the view hierarchy between those markers to locate the corresponding UIKit or AppKit instance. Once found, you can customize that underlying view directly through a closure.

The tool is suitable for production use because it relies only on public APIs and takes a defensive approach: it makes no hard assumptions about layout, performs no forced type casts, and gracefully ignores introspection requests when the expected underlying view cannot be found. You should adopt it when you need to bridge SwiftUI's declarative model with platform-specific customizations that have no SwiftUI equivalent. The library supports a range of view types and allows you to introspect either the direct receiver or an ancestor view by setting the scope parameter. Future OS releases require explicit opt-in through version markers because underlying UIKit and AppKit types can change between major versions.

The project maintains a straightforward approach to development, with clear documentation of how introspection works and explicit guidance on when and how to use it safely. The README emphasizes that instances should be kept outside the customize closure to avoid unintended side effects, and it provides guidelines for library authors considering whether to depend on this tool. The project includes examples and supports implementing custom introspectable types for views not yet covered by the built-in support.