Face ID for Xcode 9 GM unable to evaluate

I'm running Xcode 9 GM with iPhone X in simulator however evaluatePolicy for Face ID keeps failing. Is there a setting I am missing to use this new feature?

  • Xcode 9 GM
  • Simulator device iPhone X

    Hardware > Face ID > Enrolled

  • Deployment Target 11.0


Below is the code referenced from docs

let myContext = LAContext()
let myLocalizedReasonString = <#String explaining why app needs authentication#>

var authError: NSError?
if #available(iOS 8.0, macOS 10.12.1, *) {
    if myContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &authError) {
        myContext.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: myLocalizedReasonString) { success, evaluateError in
            if success {
                // User authenticated successfully, take appropriate action
            } else {
                // User did not authenticate successfully, look at error and take appropriate action
            }
        }
    } else {
        // Could not evaluate policy; look at authError and present an appropriate message to user
    }
} else {
    // Fallback on earlier versions
}
Answered by Engineer in 259735022

FaceID does not work in the Xcode 9 GM due to a framework bug.


For now the best thing to do is to test on an iPhone 8 and ensure everything works with Touch ID.

I didn't get this warning when I created/accessed stored credentials using SecItemAdd/SecItemCopyMatching with class kSecClassGenericPassword in the same way as for Touch ID. What interface triggers the warning? That is, which interface requires NSFaceIDUsageDescription?

>In the simulator, the Face ID permissions alert will show "This app was designed to use Touch ID and may not fully support Face ID" if that key is missing. On an actual device, your app will crash the same as if any other required usage string is missing.


Does that mean that an app which is in the store now - so it obviously misses the NSFaceIDUsageDescription key in its Info.plist - will crash on iPhone X if it is not updated in advance to include that key?

This is happening on my devices too, even with the iOS 11.1 beta and the Xcode 9.1 beta. Did you ever find a workaround or did it start working for you after the updates? Thanks!

No. This affects apps linked with the iOS 11 SDK. Apps linked against older SDKs should work fine with Face ID.


--gc

The iPhoneX simulator is now working for faceID. However, i've come across a slightly different issue.

I was testing some negative flows around faceID and denied the permission for faceID. This had the result of returning LAErrorBiometryNotAvailable when calling canEvaluatePolicy.

If you now jump to app settings to turn on the permission there are no options for biometry/faceID.

Is there any way to turn the permission back on in the simulator? or do I need to reset.

Thanks for the clarification. Does that mean that an app's access to Face ID will be controllable via the Privacy settings as for e.g. Location Services?

AFAICT this alert cannot be avoided, only customized in the same way the other features falling under "Privacy" can - by providing a suitable purpose string.

So if an app is released to the store compiled for iOS11 and the app uses the local auth framework with LAPolicyDeviceOwnerAuthenticationWithBiometrics to accept Touch ID, the app is bound to crash on iPhoneX whenever a TouchID is requested unless the developer remembers to add in NSFaceIDUsageDescription.


I think many apps will fall into this trap.

Thanks for the information. It works great when I intend to show FaceID for authentication to use the app.


In applying the strategy to auto prompt Face ID for authentication when bringing the app from background (or within a viewDidAppear lifecycle), however, the evaulatePolicy method call gives a failure result with error as below.


Optional(Error Domain=com.apple.LocalAuthentication Code=-10 "Lost connection to coreauthd." UserInfo={NSLocalizedDescription=Lost connection to coreauthd.})


Is it expected?

I got the same error:

Lost connection to coreauthd.

on XCode 9.01 or XCode 9.1 beta.

Sounds like maybe coreauthd crashed... Do you have a crash log? Can you please file a radar with a `sudo sysdiagnose` and `xcrun simctl diagnose`?

This is addressed in Xcode 9.0.1.

so an app that is in the store now that is linked with ios 11 SDK and doesn't have the plist key will crash

How did we get the privacy Face ID permission alert delegate reference. I need to update the UI, if user choose Don't Allow action on the popup.

I'm not sure if it's intentionally or just a buggy build/test setup on our side, but until SDK iOS 11.2 we didn't encouter the missing key at all. As we moved from Xcode 9.2 to Xcode 9.4 the base SDK changed to 11.4 and suddendly we encountered the issue with the missing NSFaceIDUsageDescription key.
I just wanted to bring this up, if there is something fishing going on as I can't confirm nor deny if that's only us.

Face ID for Xcode 9 GM unable to evaluate
 
 
Q