FaceID changes in iOS 18

I currently do FaceID validation in my apps but it looks like Apple is offering FaceID ad the App level. Does this mean we still need to or can code for it in iOS 18 apps? Right now I've been working on migrating to iOS 18 using beta but my swift code just returns an "unknown error". From a developer perspective I can't find any examples or guidance on how handle FaceID currently in iOS 18 or going forward.

Anyone have any insights or resources.

This is the code that used to work but now under iOS 18 returns the error. Maybe the simulator and swift have not caught up but I don't think so given that it's been two beta release that I know of where this has not worked.

    class biometric {
        class func authenticateUser() async -> (Bool, Error?) {
            let context = LAContext()
            var error: NSError?
            
            if context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) {
                let biometryType = context.biometryType
                var reason = "Authenticate with \(biometryType)"
                if biometryType == .faceID {
                    reason = "Authenticate with Face ID"
                } else if biometryType == .touchID {
                    reason = "Authenticate with Touch ID"
                }
                
                do {
                    let success = try await context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: reason)
                    LogEvent.print(module: "Authentication.biometric.authenticateUser", message: "Biometric authentication. success: \"\(success)\".")
                    return (success, nil)
                } catch let evaluationError as LAError {
                    LogEvent.print(module: "Authentication.biometric.authenticateUser", message: "Biometric authentication failed. evaluationError: \"\(evaluationError.localizedDescription)\"")
                    handleEvaluationError(evaluationError)

I do get past the .canEvaluatePolicy but fail on the .evaluatePolicy

Answered by OpExNetworks in 802391022

I updated to latest beta on the device and now works on device so it's just the simulator that looks like its having trouble. Thanks for your help. Hopefully, can sort out what's going on in the simulator. I'm using an iphone11 Pro

Three beta releases, code is current and correct yet still does not work. Buelher? Anybody? Anybody?

Does this mean we still need to or can code for it in iOS 18 apps?

The iOS 18 app lock feature is a user-level feature. It’s still reasonable for you to secure your app with your own Face ID authentication.

As to why your code is failing, it’s hard to say without more details. I can say that I’ve not seen a flood of developers reporting Face ID problems, so there’s something specific about your app that’s triggering it. That could be a bug in your code, or just something weird about your app that’s triggering an OS-level bug.

If you print the full error, what do you get back?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Here is a simple example:


struct ContentView: View {
    @State private var isUnlocked = false
    var body: some View {
        VStack {
            if isUnlocked {
                Text("Unlocked")
            } else {
                Text("Locked")
            }
        }
        .padding()
        .onAppear(perform: authenticate)
    }
}

import LocalAuthentication
func authenticate() {
    let context = LAContext()
    var error: NSError?

    // check whether biometric authentication is possible
    if context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) {
        // it's possible, so go ahead and use it
        let reason = "We need to unlock your data."

        context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: reason) { success, authenticationError in
            // authentication has now completed
            if success {
                // authenticated successfully
            } else {
                // there was a problem
                if let error = authenticationError as? NSError {
                    print("Authentication failed: \(error), \(error.userInfo)")
                } else {
                    print("Authentication failed: \(String(describing: authenticationError))")
                }
            }
        }
    } else {
        // no biometrics
    }
}

Here is the error it spits back:

Authentication failed: Error Domain=com.apple.LocalAuthentication Code=-1000 "UI service connection invalidated." UserInfo={NSDebugDescription=UI service connection invalidated., NSLocalizedDescription=Authentication failure.}, ["NSDebugDescription": UI service connection invalidated., "NSLocalizedDescription": Authentication failure.]

I get this error pop up from Xcode: "CoreAuthUI quit unexpectedly."

This may help from the Problem Report:

-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Incident Identifier: 44ECD006-5C1C-4E2B-A580-003F46E298E5
CrashReporter Key:   74F42D79-158E-2606-618B-4DC2CCB64CD7
Hardware Model:      Mac15,9
Process:             CoreAuthUI [13984]
Path:                /Volumes/VOLUME/*/CoreAuthUI.app/CoreAuthUI
Identifier:          com.apple.CoreAuthUI
Version:             1.0 (1656.40.15)
Code Type:           ARM-64 (Native)
Role:                Foreground
Parent Process:      launchd_sim [13492]
Coalition:           com.apple.CoreSimulator.SimDevice.BCC8C055-BE32-4735-BA12-890CFD1512FC [3618]
Responsible Process: SimulatorTrampoline [1694]

Date/Time:           2024-09-02 21:20:46.9564 -0700
Launch Time:         2024-09-02 21:20:46.4760 -0700
OS Version:          macOS 14.6.1 (23G93)
Release Type:        User
Report Version:      104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Termination Reason: SIGNAL 6 Abort trap: 6
Terminating Process: CoreAuthUI [13984]

I have the plist entry:

Privacy - Face ID Usage Description = "Allow the app to use FaceID"

That crash report is from the simulator. Do you see the same problem on a real device?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I updated to latest beta on the device and now works on device so it's just the simulator that looks like its having trouble. Thanks for your help. Hopefully, can sort out what's going on in the simulator. I'm using an iphone11 Pro

now works on device

Excellent news.

Hopefully, can sort out what's going on in the simulator.

Rather than hope, I recommend that you file a bug against the simulator. Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Accepted Answer

Here is the bug number in feedback assistant: FB15037288

I am seeing the same issue in the release iOS18 simulator.

Works fine, on-device, and on the iOS17 simulator.

The only issue is the iOS18 simulator.

I did not test the iOS18 SIMULATOR, because I didn't want to use an unreleased Xcode. I did test on an iOS18 device, though, and that never showed a problem.

submitted feedback with attached code snippet and system error popup:

15155625

I'm experiencing the same issue in my app. Is there a solution/workaround?

Have you tried with Xcode 16.1 beta? Looking at the first bug mentioned above (FB15037288), there’s evidence to suggest that it’s fixed there.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

FaceID changes in iOS 18
 
 
Q