HealthKit requestAuthorization dialog does not show

When calling

HKHealthStore.requestAuthorization(toShare:read:completion:)

in an app that uses a SceneDelegate this results in

[Assert] Error in UIKit client: -[UIWindow setScreen:] should not be called if the client adopts UIScene lifecycle. Call -[UIWindow setWindowScene:] instead.

which makes using HealthKit impossible at all. NSHealthShareUsageDescription is set. It happens from beta 1 up to the current beta 4.


Does anybody have a solution for this?

Replies

I've been seeing the error as well on anything developed with UIKit that presents new views. I'm not sure it's not an unfinished underlying api issue with the new separation of functionality into SceneDelegate from AppDelegate, as nowhere in any of my project code do I directly call setScreen.


That said, if you (or anyone else) knows the cause/solution I'd love to know as well.

A workaround is to not use the UIWindowSceneDelegate API.


I had a new iOS 13 project so I had to:

1. Remove "Application Scene Manifest" key from Info.plist

2. Adjust code to setup UIWindow in the UIApplicationDelegate instead of the UIWindowSceneDelegate.

Also seeing this - did you find a solution?

Can you provide more details on how to do this? I'm not sure I understand. I've removed the Application Scene Manifest but I'm not slear on the code changes I need to make.


Thanks!

Resolved in beta 5

resolved in beta 5