Vision and iOS18 - Failed to create espresso context.

I'm playing with the new Vision API for iOS18, specifically with the new CalculateImageAestheticsScoresRequest API. When I try to perform the image observation request I get this error:

internalError("Error Domain=NSOSStatusErrorDomain Code=-1 \"Failed to create espresso context.\" UserInfo={NSLocalizedDescription=Failed to create espresso context.}")

The code is pretty straightforward:

if let image = image {
    let request = CalculateImageAestheticsScoresRequest()
    
    Task {
        do {
            let cgImg = image.cgImage!
            let observations = try await request.perform(on: cgImg)
            let description = observations.description
            let score = observations.overallScore
            print(description)
            print(score)
        } catch {
            print(error)
        }
    }
}

I'm running it on a M2 using the simulator. Is it a bug? What's wrong?

This is expected behavior as the simulator lacks the capability to run this request. Running on an actual device will resolve the issue.

Dear Apple,

Is there ANY workaround to run this on iOS 18 simulator? I am writing XCUITests that are running on the simulator in the cloud, and they need to compare actual image vs expected image for similarity. I first did strict PNG Data comparison but it was too prone to flaking when the slightest change was made to the code or a dependency library. So trying to use the Vision APIs (like CalculateImageAestheticsScoresRequest) for some proxy score I can use to detect image similarity within a tolerance level.

Thanks in advance!

Vision and iOS18 - Failed to create espresso context.
 
 
Q