CheckOps home

Tools directory

V

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.

Visit website

Latest public signals

Not refreshed yet. Refresh reads the public site and, when the entry has a GitHub repository, the latest release.

Visit Website

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

  1. Unit-test SwiftUI: No UI test runner needed.
  2. Hierarchy search: Find views by type, text, ID or label.
  3. Interaction: Tap buttons, toggle and edit fields.
  4. Broad platform support: iOS, macOS, tvOS, watchOS and visionOS.

Pros

  1. Free to use: Open source under the MIT licence, so the core tool costs nothing to use.
  2. Actively maintained: The repository had commits as recent as 15 October 2026.

Cons

  1. Relies on SwiftUI internals: New OS versions can require library updates.
  2. Coverage gaps: Not every view or modifier is supported; check the coverage document.
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.

  1. SwiftUI developers wanting fast unit tests for view logic.
  2. 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.