DEV.co
Open-Source Testing · lyft

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.

Source: GitHub — github.com/lyft/Hammer
705
GitHub stars
39
Forks
Swift
Primary language
Apache-2.0
License (OSI-approved)

Key facts

Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.

FieldValue
Repositorylyft/Hammer
Ownerlyft
Primary languageSwift
LicenseApache-2.0 — OSI-approved
Stars705
Forks39
Open issues6
Latest release0.18.0 (2025-12-03)
Last updated2025-12-03
Sourcehttps://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.

Quickstart

Get the Hammer source

Clone the repository and explore it locally.

terminalbash
git clone https://github.com/lyft/Hammer.gitcd Hammer# follow the project's README for install & configuration

Need it deployed, integrated, or customized instead? DEV.co ships production installs.

Best use cases

Complex gesture UI testing

Validate multi-touch interactions like pinch, rotate, and long-press gestures that are difficult to test with standard XCTest touch simulation.

Drawing and stylus-enabled apps

Test iPad stylus input with pressure, altitude, and azimuth properties in drawing, annotation, or creative applications.

Navigation and animation timing

Test screen transitions and tap sequences with realistic touch timing and visibility waits, useful for apps with complex animation states.

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.

SignalAssessment
MaintenanceActive
DocumentationAdequate
License clarityClear
Deployment complexityModerate
DEV.co fitGood
Assessment confidenceHigh
Security considerations

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.

Software development agency

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.co

Related 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?
No. Hammer relies on private APIs and is designed only for test targets. Shipping it in production violates App Store guidelines and will likely be rejected.
Why do I get 'View is not in hierarchy' errors?
The view must be in the same UIWindow hierarchy as the EventGenerator's window, and it must be added to the view controller hierarchy. Check that your test setup properly presents the view controller or adds the view to the window.
Do I need a real device to run Hammer tests?
No, the simulator works. However, your test target must have a configured host application (main app or a test wrapper). SwiftPM projects require creating an xcodeproj to satisfy this requirement.
How does Hammer differ from XCTest's native tap/pinch methods?
Hammer synthesizes low-level touch events with fine-grained control (finger index, pressure, azimuth, interpolation), enabling complex multi-touch gestures and stylus input. XCTest's high-level methods are simpler but less flexible and do not support stylus.

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.