Run an XCUITest with leak detection (CI-runnable)
detectLeaksInXCUITestDetect new retain cycles in XCUITest runs by diffing memory graph snapshots before and after a test cycle, failing CI when unexpected leaks appear.
Instructions
[mg.ci] Build the workspace for testing, launch the test cycle, capture a baseline .memgraph once the app appears, run the test to completion, capture an after .memgraph, and diff. Returns passed: false when new ROOT CYCLE blocks appear that aren't in the allowlistPatterns list. Designed for CI gating: non-zero exit code on failure.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workspace | Yes | Path to the .xcworkspace or .xcodeproj for the project. | |
| scheme | Yes | Xcode scheme that builds and runs the XCUITest target. | |
| testIdentifier | Yes | XCUITest identifier in `<TestTarget>/<TestClass>/<testMethod>` form. Passed to `-only-testing` so we run exactly one test cycle. | |
| appName | Yes | App process name as it appears in `pgrep -x` (e.g. "DemoApp"). | |
| destination | No | xcodebuild destination string. Default targets the most common iOS Simulator profile. | platform=iOS Simulator,name=iPhone 11,OS=latest |
| outputDir | No | Directory where the baseline + after `.memgraph` snapshots are written. | /tmp/memorydetective-xcuitest |
| allowlistPatterns | No | Substrings of class names that are allowed to leak. Examples: pre-existing SwiftUI internals you can't fix, third-party SDK leaks. Cycles whose root class contains any of these substrings won't fail the run. | |
| skipBuild | No | Skip the build-for-testing step (faster on CI when the build is already cached). | |
| outputHtmlPath | No | Absolute path to write a self-contained HTML report (inline CSS, no external assets). When set, the response also gains an `htmlReportPath` field pointing at the same file. Designed for CI artifact upload + PR-comment attachment. |