Search code examples
iosxcodecucumberfrank

How can I Enroll Touch ID in Simulator from the command line?


I want to enroll Touch ID in the iOS Simulator from the command line so I can run some automated UI feature tests around authorization.

I've tried a few things that didn't work:

  • xcrun simctl doesn't have a Touch ID option
  • an AppleScript to control the menu didn't work because osascript doesn't have accessibility permissions (and I don't like this invasive workaround)
  • I tried editing the simulator's plist before launch but couldn't find an appropriate key value pair

If it matters, I'm using Frank and Cucumber for the tests.


Solution

  • xcrun simctl spawn 'iPhone X' notifyutil -s com.apple.BiometricKit.enrollmentChanged '1' && xcrun simctl spawn 'iPhone X' notifyutil -p com.apple.BiometricKit.enrollmentChanged
    

    This will enroll fingerprint. Code taken from here

    Edit: You can use this for finger touch:

    xcrun simctl spawn 'iPhone X' notifyutil -p com.apple.BiometricKit_Sim.fingerTouch.match
    xcrun simctl spawn 'iPhone X' notifyutil -p com.apple.BiometricKit_Sim.fingerTouch.nomatch