CheckOps
ViewInspector
ViewInspector is an MIT-licensed library for unit testing SwiftUI views at runtime, letting tests traverse the view hierarchy, read values and trigger actions such as button taps.
Latest public signals
Not refreshed yet. Refresh reads the public site and, when the entry has a GitHub repository, the latest release.
Introduction
ViewInspector is a library for unit testing SwiftUI views. SwiftUI views are value types with opaque bodies, which makes them hard to test without running a UI test. ViewInspector uses runtime introspection to let tests traverse the view hierarchy, inspect values and simulate user interaction directly in fast unit tests.
You call try view.inspect() and navigate with methods such as find(button: "Back"), find(text:), find(viewWithId:) or find(CustomView.self), then read properties (text strings, images, modifiers, styles) or trigger actions like .tap(), toggles and text entry. Custom views can be unwrapped with actualView() to check state. The project maintains an API coverage document listing which SwiftUI views and modifiers are inspectable. It supports iOS, macOS, tvOS, watchOS and visionOS, and works with XCTest and other runners. Version 0.10.5 was released on 30 September 2026.
The source code is at nalexn/ViewInspector on GitHub under the MIT licence, with about 2,600 stars; the most recent commit was on 15 October 2026.
Features
- Unit-test SwiftUI: No UI test runner needed.
- Hierarchy search: Find views by type, text, ID or label.
- Interaction: Tap buttons, toggle and edit fields.
- Broad platform support: iOS, macOS, tvOS, watchOS and visionOS.
Pros
- Free to use: Open source under the MIT licence, so the core tool costs nothing to use.
- Actively maintained: The repository had commits as recent as 15 October 2026.
Cons
- Relies on SwiftUI internals: New OS versions can require library updates.
- Coverage gaps: Not every view or modifier is supported; check the coverage document.
Usage and Links (Example)
import XCTest
import ViewInspector
@testable import Shop
final class CounterViewTests: XCTestCase {
func testIncrement() throws {
let model = CounterModel()
let sut = CounterView(model: model)
try sut.inspect().find(button: "Increment").tap()
XCTAssertEqual(model.count, 1)
XCTAssertEqual(try sut.inspect().find(viewWithId: "count").text().string(), "1")
}
}
Resources:
Pricing
ViewInspector is free and open source under the MIT licence.
Recommended for?
- SwiftUI developers wanting fast unit tests for view logic.
- Teams reducing slow UI test suites.
Conclusion
ViewInspector fills an important gap by making SwiftUI views unit-testable, complementing snapshot and UI tests.
Alternatives
Other tools on CheckOps that cover similar ground. Open a page, or compare one with ViewInspector side by side.
SSnapshotTesting (Point-Free)SnapshotTesting is Point-Free's MIT-licensed snapshot testing library for Swift, snapshotting views, view controllers and any value as images, text, JSON and more, with XCTest and Swift Testing support.Compare with ViewInspector
XXCTestXCTest is Apple's testing framework for unit, performance and UI tests in Xcode projects across Apple platforms, with assertions, expectations for async code, performance metrics and code coverage.Compare with ViewInspector
SSwift TestingSwift Testing is Apple's open-source (Apache-2.0) testing library for Swift, using @Test and #expect macros, parameterised tests, traits and parallel execution, included in Xcode 16 and Swift 6 toolchains.Compare with ViewInspector
NNimbleNimble is an Apache-2.0 matcher framework for Swift and Objective-C, offering expressive expect(...).to(...) assertions and asynchronous toEventually expectations, used with XCTest or Quick.Compare with ViewInspector
XXCUITestA test automation framework for iOS applications, part of the XCTest framework.Compare with ViewInspector
JJetpack Compose UI testingJetpack Compose's testing APIs (ui-test-junit4) let Android developers find, assert on and interact with composables through semantics, using createComposeRule on devices or with Robolectric on the JVM.Compare with ViewInspector