ios – CoreHaptics on Swift error _Haptic_Check: -[CHHapticEngine(CHHapticEngineInternal) checkEngineStateOnStart:]


I have been trying to create custom vibrations for my app using CoreHaptics on a new SwiftUI app. To make my code neat, I separated the function that creates and starts the CHHapticEngine from the function that runs the haptic pattern like so:

static func StartEngine() throws {
   //...
    do
    {
        var engine = try? CHHapticEngine()
            
        try engine?.start()
    }
   //...
}

static func RunWithPattern(pattern: CHHapticPattern) throws {
    //...
    do
    {
        var engine = try CHHapticEngine()
        let player = try engine.makePlayer(with: pattern)
        try player.start(atTime: 0)
    } 
    //...
}

Running this gives me this error in the console, and no haptics felt on the device: HapticUtils.h:59 _Haptic_Check: -[CHHapticEngine(CHHapticEngineInternal) checkEngineStateOnStart:]: self.running error -4805.

I got 0 hits on google, even when using generic parts of that error message, hence asking the question here.

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img