Catch broken Auto Layout constraints during test execution using LLDB breakpoints, and surface them as PR warnings via Danger.
UIViewAlertForUnsatisfiableConstraints fires at runtime but is invisible in CI. Broken constraints silently ship to production, causing layout bugs that are hard to trace back to a specific change.
This project demonstrates a technique to intercept these warnings during tests and block them at the PR level.
- Sets an LLDB breakpoint on
UIViewAlertForUnsatisfiableConstraintsthat runs in the background during test execution - A Python script attached to the breakpoint walks the call stack, identifies the failing
XCTestCase, and logs it tobrokenConstraints.txt - Danger reads the output file and posts constraint violations as warnings on the pull request
- See PR #3 for an example of the Danger output
- Xcode 14.1+
- macOS (CI runs on
macos-latest) danger-swift(installed via Homebrew in CI)
# Run tests locally
make test
# Run LLDB constraint detection (background) + tests
lldb --source lldb-command &
make test- LLDB attaches to the test process and sets a breakpoint on
UIViewAlertForUnsatisfiableConstraintswith auto-continue enabled - On each hit, a Python command iterates the thread's frames, finds the
XCTestCasesubclass, and appends the module/file/function tobrokenConstraints.txt - After tests complete, Danger checks for the output file and warns on the PR with the logged violations
Defined in .github/workflows/snapshot.yml, triggered on pull requests:
checkout -> lldb --source lldb-command & -> make test -> danger-swift ci
lldb-command # LLDB breakpoint script (Python)
Dangerfile.swift # Danger config - reads constraint errors, warns on PR
Makefile # xcodebuild wrapper
constraint-error-ci-example/
BrokenView.swift # UIView with intentionally broken constraints (demo)
constraint-error-ci-snapshots/
BrokenViewTests.swift # Snapshot tests that trigger constraint violations
- LLDB must attach to the process before tests start - requires background launch (
&) - The
lldb-commandscript relies onGITHUB_WORKSPACEenv var, so local runs won't write tobrokenConstraints.txtwithout modification - Only detects constraints broken during test execution - no static analysis
MIT