# ViewInspector

> Unit testing for SwiftUI views by inspecting the view hierarchy at runtime

Source: https://talira.ai/catalog/viewinspector-gav38xak
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Types: Library
- Categories: [developer tools / testing / mobile](https://talira.ai/categories/developer-tools/testing/mobile), [languages / swift](https://talira.ai/categories/languages/swift)
- Licence: MIT[^1]
- Pricing: Free and open source[^1]
- Free tier: yes[^1]
- Backed by: [Alexey Naumov](https://talira.ai/orgs/nalexn.md)

ViewInspector is a Swift library for unit testing [SwiftUI](https://talira.ai/catalog/swiftui-77sr6dby.md) views. It walks a view hierarchy at runtime with Swift's official reflection API, so a test can find views by type or condition, read standard views' contents and attributes (a `Text`'s string in a given locale, its font), get a custom view's actual state (`@State`, `@Binding`, `@ObservedObject`, `@EnvironmentObject`), and trigger callbacks such as a button tap or `onAppear`, with helpers for asynchronous tests. It goes in the unit-test target only.

## Links

- GitHub: https://github.com/nalexn/ViewInspector

## Problems it solves

- write unit tests that check what my SwiftUI view actually shows
- tap a button in a SwiftUI view from an XCTest without running UI tests
- assert on the state inside a SwiftUI view in a unit test

## Features

- find views by type, text or condition in a SwiftUI hierarchy
- read standard views' values and attributes
- access a custom view's state, bindings and observed objects
- tap buttons and call onAppear and other callbacks from tests

## Trust

Overall: 0.59 out of 1.
Signals: maintenance 0.82, adoption 0.68, momentum 0.46, community 0.72, backing 0.30, extensibility 0.00.

- last commit 45 days ago
- 56 commits in the last 90 days
- latest release 0.10.5 2 months ago
- 2.6k GitHub stars
- 62 contributors
- backed by Alexey Naumov

## Related

- Works with [SwiftUI](https://talira.ai/catalog/swiftui-77sr6dby.md)

## Sources

[^1]: https://github.com/nalexn/ViewInspector/blob/master/LICENSE (checked 28 Nov 2026)
