Mac hosting guide

iOS Simulator Face ID Biometric Test Script

Post the Simulator's Face ID Darwin notifications with xcrun simctl spawn notifyutil from a helper inside XCUITest, then assert the UI and attach a screenshot. The Simulator provides the biometric, so no Face ID hardware is needed.

Figment editorial teamPublished Updated Facts checked November 10, 2026

Figment Mac plans

US East. Pay before use. Hourly and daily too.

Intel Mac VM4 shared vCPUs, 4GB RAM, 80GB SSD$25per monthApple Silicon Mac VM4 shared vCPUs, 4GB RAM, 65GB SSD$39per monthDedicated M4 Pro12-core CPU, 24GB RAM, 512GB SSD$199per month

Minimum first purchase: $25 of account credit, used for your rental.

Post the documented Darwin notifications with xcrun simctl spawn … notifyutil from a BiometricSimulator helper inside XCUITest, then assert on the resulting UI and attach a screenshot. The iOS Simulator supplies the Face ID outcome, so the test needs no Face ID hardware, only a Mac with Xcode.

Manual Face ID testing in the Simulator is a menu click: Features → Face ID → Matching Face. CI needs the same outcomes without touching the GUI, on every build, with evidence. The approach below gives you two XCUITests (match and non-match), a reusable helper, and a reset step that leaves the Simulator in a known state between runs.

How do I enroll Face ID and post biometric notifications?

Use xcrun simctl spawn <udid> notifyutil. The Simulator reacts to Darwin notifications posted inside its own sandbox, and there is no public xcrun simctl biometric subcommand. These notification names are undocumented Darwin internals that have worked across recent Xcode releases, so verify them against the Xcode you have installed before you trust them in a release pipeline.

# Pick the booted simulator UDID
UDID=$(xcrun simctl list devices booted -j \
  | python3 -c "import sys,json;d=json.load(sys.stdin)['devices']; \
    print(next(x['udid'] for r in d.values() for x in r if x['state']=='Booted'))")

# Enrol Face ID
xcrun simctl spawn "$UDID" notifyutil \
  -s com.apple.BiometricKit.enrollmentChanged 1 \
  -p com.apple.BiometricKit.enrollmentChanged

# Matching face  -> authentication success
xcrun simctl spawn "$UDID" notifyutil -p com.apple.BiometricKit_Sim.pearl.match

# Non-matching face -> authentication failure
xcrun simctl spawn "$UDID" notifyutil -p com.apple.BiometricKit_Sim.pearl.nomatch

For Touch ID, swap pearl for fingerTouch. These commands are the tool, and the test logic is in XCUITest.

How do I wire LAContext into the app under test?

Call LAContext.evaluatePolicy from your app to present the biometric prompt. The documentation for LAContext requires NSFaceIDUsageDescription in Info.plist, and without it authorisation requests may fail. The test launches the app, taps the button that calls evaluatePolicy, then resolves the prompt by posting the pearl.match or pearl.nomatch notification.

// App code (not the test target)
import LocalAuthentication

func authenticate(_ completion: @escaping (Bool, Error?) -> Void) {
    let ctx = LAContext()
    var err: NSError?
    guard ctx.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &err) else {
        completion(false, err); return
    }
    ctx.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics,
                       localizedReason: "Sign in to your account") { ok, e in
        DispatchQueue.main.async { completion(ok, e) }
    }
}

What do the helper and the two XCUITests look like?

Use a small helper that shells out to notifyutil from the test process, plus one test per outcome that asserts on the UI and captures a named screenshot.

// BiometricSimulator.swift (UI test target)
import Foundation
import XCTest

enum FaceIDOutcome { case match, nonMatch }

struct BiometricSimulator {
    @discardableResult
    static func trigger(_ outcome: FaceIDOutcome, udid: String) -> Bool {
        let name = outcome == .match
            ? "com.apple.BiometricKit_Sim.pearl.match"
            : "com.apple.BiometricKit_Sim.pearl.nomatch"
        let p = Process()
        p.executableURL = URL(fileURLWithPath: "/usr/bin/xcrun")
        p.arguments = ["simctl", "spawn", udid, "notifyutil", "-p", name]
        do {
            try p.run(); p.waitUntilExit()
            return p.terminationStatus == 0
        } catch {
            XCTFail("BiometricSimulator: \(error)"); return false
        }
    }
}
// FaceIDAuthTests.swift (UI test target)
import XCTest

final class FaceIDAuthTests: XCTestCase {
    let udid = ProcessInfo.processInfo.environment["SIMULATOR_UDID"] ?? "booted"
    var app: XCUIApplication!

    override func setUp() {
        super.setUp()
        continueAfterFailure = false
        app = XCUIApplication()
        app.launchEnvironment["BIOMETRIC_TEST_MODE"] = "1"
        app.launch()
    }

    func testFaceIDMatchUnlocksApp() {
        app.buttons["Sign In with Face ID"].tap()
        // The system Face ID sheet is drawn outside the app's a11y tree on some
        // simulator builds, so wait briefly rather than asserting on app.alerts.
        Thread.sleep(forTimeInterval: 1.0)
        XCTAssertTrue(BiometricSimulator.trigger(.match, udid: udid))

        let dashboard = app.staticTexts["Welcome back"]
        XCTAssertTrue(dashboard.waitForExistence(timeout: 3),
                      "Dashboard did not appear after match")
        attach(name: "face-id-match-success")
    }

    func testFaceIDNonMatchShowsPasscodeFallback() {
        app.buttons["Sign In with Face ID"].tap()
        Thread.sleep(forTimeInterval: 1.0)
        XCTAssertTrue(BiometricSimulator.trigger(.nonMatch, udid: udid))

        let passcode = app.buttons["Use Passcode"]
        XCTAssertTrue(passcode.waitForExistence(timeout: 3),
                      "Passcode fallback did not appear after non-match")
        attach(name: "face-id-nonmatch-fallback")
    }

    private func attach(name: String) {
        let a = XCTAttachment(screenshot: app.screenshot())
        a.name = "\(name).png"; a.lifetime = .keepAlways
        add(a)
    }
}

Pass SIMULATOR_UDID from CI when you run several simulators in parallel, and fall back to booted for a single-simulator job. Replace the button titles and the success text with the real strings from your app.

How do I reset enrollment between runs?

Flip enrollment off and on before each job. Residual enrollment from a previous run makes the prompt appear in a surprising state, so add this as a pre-test step and every job starts from the same place.

xcrun simctl boot "$UDID" || true

xcrun simctl spawn "$UDID" notifyutil \
  -s com.apple.BiometricKit.enrollmentChanged 0 \
  -p com.apple.BiometricKit.enrollmentChanged

xcrun simctl spawn "$UDID" notifyutil \
  -s com.apple.BiometricKit.enrollmentChanged 1 \
  -p com.apple.BiometricKit.enrollmentChanged

Run this before xcodebuild test so setUp() does not have to manage enrollment. If xcodebuild returns non-zero, fail the job. A failed build is a failure, not a biometric data point.

Can a Linux runner replace a Mac for Face ID simulation?

Face ID simulation runs inside a macOS process, and XCUITest, xcrun simctl spawn and notifyutil exist only on macOS, so a Linux runner cannot substitute. The Intel Mac VM ($25 a month, $2 a day) runs macOS Sequoia and fits one Simulator with Xcode 26.3 or earlier, per Apple's porting guide. The Apple Silicon Mac VM ($39 a month, $6 a day) fits Xcode 26.4 or later and visionOS.

Real Face ID hardware tests are not available on any Figment plan. They need a physical iPhone or iPad you control. For parallel simulators the Dedicated M4 Pro 48 GB (48GB, $349 a month, or $299 a month on a 12-month term) has the memory, and we have not measured a simulator count on any plan. See the Mac hosting plans.

For market context, CloudMac publishes $99.99/month on its pricing page and a $999/year offer on its homepage, about $83.25/month effective for an M4 with 16 GB and 256 GB (the 256 GB tier showed "Reserve now", and the 512 GB and 1 TB tiers were fully reserved). CloudMac lists a whole Mac, so the nearer Figment match is the Dedicated M4 Pro.

OptionMonthly12-month costHardware
Figment Intel Mac VM$25$300 (12 × $25)4 shared vCPUs, 4GB, 80GB, Intel
Figment Apple Silicon Mac VM$39$468 (12 × $39)4 shared vCPUs, 4GB, 65GB
Figment Dedicated M4 Pro 48 GB$349$3,228 (12 months paid up front)Whole Mac, 48GB, 512GB
CloudMac M4 monthly$99.99$1,199.88M4, 16 GB, 256 GB
CloudMac M4 annual$83.25 effective$999M4, 16 GB, 256 GB

If you run the test on a self-hosted GitHub runner, follow GitHub's secure-use guide.

Related guides:

Which Figment Mac fits this work?

Intel Mac VM from $25 a month, Apple Silicon Mac VM from $39, or a Dedicated M4 Pro for $199. Hourly and daily plans too. You pay before use, starting with at least $25 of account credit.

Choose a Mac plan