Hammer
Hammer is a Swift library for iOS that simulates user touch, stylus, and keyboard interactions in unit tests. Built by Lyft and maintained actively, it enables realistic UI testing by emulating real-world user gestures rather than direct UI manipulation.
Key facts
Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.
| Field | Value |
|---|---|
| Repository | lyft/Hammer |
| Owner | lyft |
| Primary language | Swift |
| License | Apache-2.0 — OSI-approved |
| Stars | 705 |
| Forks | 39 |
| Open issues | 6 |
| Latest release | 0.18.0 (2025-12-03) |
| Last updated | 2025-12-03 |
| Source | https://github.com/lyft/Hammer |
What Hammer is
Hammer synthesizes UIKit touch events (fingers, stylus, keyboard) for iOS 11+ via private APIs, supporting primitive events (down/move/up) and high-level gestures (tap, pinch, rotate, drag). It requires a host application to execute tests and provides view discovery by accessibility identifier with timeout support.
Get the Hammer source
Clone the repository and explore it locally.
git clone https://github.com/lyft/Hammer.gitcd Hammer# follow the project's README for install & configurationNeed it deployed, integrated, or customized instead? DEV.co ships production installs.
Best use cases
Implementation considerations
- Host application setup is mandatory: configure test target host app in Xcode General tab. Consider a lightweight TestHost wrapper to avoid coupling to the main app.
- Private API usage means the library may break on new iOS releases; validate against target iOS versions during integration and CI/CD.
- Accessibility identifiers must be present on target views; requires coordination with app code to assign IDs for testability.
- Tests execute in a full UIApplication context, which is slower than unit test mocks but more realistic for gesture and animation validation.
- Touch interpolation and duration parameters allow realistic timing, but test flakiness from animation state timing is possible; use waitUntilVisible/waitUntilHittable with appropriate timeouts.
When to avoid it — and what to weigh
- Production app deployment required — Hammer relies exclusively on private Apple APIs and must never ship in a production app. Use only in test targets.
- Need framework-only testing without a host app — SwiftPM frameworks cannot be used directly; you must create an xcodeproj and configure a host application (main app or test wrapper) to run tests.
- Cross-platform testing strategy — Library is iOS-only (and iPad stylus). If you need Android or web testing, this does not address those platforms.
- Zero maintenance overhead expected — Private API dependencies mean changes in iOS releases can break the library; maintainers must actively track Apple's UIKit internals.
License & commercial use
Apache License 2.0 (Apache-2.0): permissive OSI-approved license allowing modification and distribution with reasonable conditions (attribution, license copy, change documentation). Suitable for most commercial and open-source projects.
Apache-2.0 permits commercial use in test code without restriction. However, private API dependency creates risk: Apple could restrict or remove private API access in future iOS versions, necessitating active maintenance. Not suitable for shipping in production apps under any circumstances.
DEV.co evaluation signals
Editorial assessment — not user reviews. Directional, with an explicit confidence level.
| Signal | Assessment |
|---|---|
| Maintenance | Active |
| Documentation | Adequate |
| License clarity | Clear |
| Deployment complexity | Moderate |
| DEV.co fit | Good |
| Assessment confidence | High |
Private API usage is a significant stability and support risk, not a security vulnerability per se. Tests execute in a real UIApplication with full access to UI state; no isolation guarantees. Suitable only for development/test environments. No security review data available.
Alternatives to consider
XCTest native touch APIs (XCUIElement.tap, pinch, etc.)
Built-in, public API, no private dependencies. Simpler for basic interactions but limited gesture fidelity and no stylus support; requires UITest target rather than unit test host app.
EarlGrey (Google)
Cross-platform (iOS, Android), mature, public API. Heavier framework with more dependencies; primarily UI automation focused rather than synthesized touch events.
Calabash / Appium
Cross-platform mobile automation. Requires external processes and server; slower iteration; overkill for unit-test-level gesture validation.
Build on Hammer with DEV.co software developers
Hammer enables realistic gesture and stylus testing via synthesized touch events. Contact us to assess whether Hammer fits your testing strategy and iOS version roadmap.
Talk to DEV.coRelated open-source tools
Surfaced by semantic similarity across the DEV.co open-source index.
Related on DEV.co
Explore the category and the services that help you build with it.
Hammer FAQ
Can I use Hammer in a production app?
Why do I get 'View is not in hierarchy' errors?
Do I need a real device to run Hammer tests?
How does Hammer differ from XCTest's native tap/pinch methods?
Work with a software development agency
From first prototype to production, DEV.co delivers software development services around tools like Hammer. Our software development agency staffs experienced software developers and web developers for custom software development, web development, integrations, and ongoing support across open-source testing and beyond.
Evaluating iOS UI testing for your app?
Hammer enables realistic gesture and stylus testing via synthesized touch events. Contact us to assess whether Hammer fits your testing strategy and iOS version roadmap.