HKHealthStore Crash

Hi there,

I posted my crashing issue before, it is called "App Crash and System Acting Weird in iOS". The crashing will happens once the application runs for a while (an predictable, could be 1 day, could be longer), it will not be reopen and the I cannot delete any app (not only my app) from my iOS deveice, and the slide bar for turn off will overlap to the other.


My app contains some healthe data background fetching, and I have added lot of local system log for the debug purpose, the implementation is like:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        window?.makeKeyAndVisible()
        
        textLog.write("\n\(Date()): didFinishLaunchingWithOptions")
        textLog.write("\n\(Date()): fetchBackgroundHealthData")
        healthStore.requestAuthorization(toShare: nil, read: readingTypes) { [weak self] (success, error) -> Void in
         guard let `self` = self else { return }
         self.textLog.write("\nhealthStore.requestAuthorization start")
         ....
        }
        ....
}

When it behave as normall, all logs will be there. However, once the crash happens, the log will be like:

didFinishLaunchingWithOptions --> fetchBackgroundHealthData

But never shows "healthStore.requestAuthrozation start". Seems like it stuck in there.


please let me know if anyone can help on this. Thank you very much.