'NSHealthUpdateUsageDescription must be set in the app's Info.plist
Asked Answered
R

1

7

Our app has captured heart rate data from HealthKit on the Apple Watch for over 2 years. However, since XCode 11, this no longer works. In fact the app crashes with the error: 'NSHealthUpdateUsageDescription must be set in the app's Info.plist. I set both the NSHealthUpdateUsageDescription and the NSHealthShareUsageDescription keys in the app's info.plist file. I have read over all the posts in all the forums with no luck as to why the app is crashing with this error, as obviously I have set the appropriate keys. I read in several posts that the description must be really long (very scientific), so I made our descriptions very long, with no luck.

We ask for permission for many other entitlements and they all work fine. In fact we have a step test that continues to work just fine on the Apple Watch as well.

I should say this, we have moved the text out of our app into localizable strings. This seemingly should not matter, because iOS continues to ask for permission for the other entitlements (Camera Usage, FaceID, Location, etc) just fine.

We have created an InfoPList.strings file as a desperate attempt to see why we continue to get this error. The thought being that apple is looking for a string and is unable to find it, so it just puts out the generic, nearly useless, error message.

<key>NSHealthShareUsageDescription</key>
<string>$(PRODUCT_NAME) would like to capture a snap shot of your heart rate for the purpose of using the data in a clinical research study. Please grant this permission to continue participating.</string>
<key>NSHealthUpdateUsageDescription</key>
<string>$(PRODUCT_NAME) would like to update your health usage with heart rate data. Actually we never do anything of the kind but it seems Apple has lost control of X-Code and has few if any answers, so we will ask this permission.</string>

Here are the key/values in the InfoPlist.strings (English) file:

NSHealthShareUsageDescription = "This App uses HealthKit to get Heart Rate from patient for Clinical Research Trial. Your Heart Rate will be stored in your secure, personal, Clinical Trial record and will be used to further medical innovation."; NSHealthUpdateUsageDescription = "This App shares Heart Rate with HealthKit";

Has anybody encountered this problem and managed to get by it? Next step is turning to Apple, which can be a very challenging task to get their attention. Thanks in advance.

Rapier answered 10/11, 2019 at 16:1 Comment(1)
post the code which crashes. my understanding is that those descs are only for approval and not for code execution.Bildungsroman
P
11

You must now also add it to the Watch Extension project info.plist. I had the same issue and it resolved by doing this.

Petticoat answered 11/11, 2019 at 15:37 Comment(2)
Thank you that solved my problem. I actually added this to both info.plist files for the extension and the WatchKit app. It errored out so I removed both, which was my fatal error. So again, you must have these keys in the main app and the watchkit extension app but cannot have the keys in the watchkit app.Rapier
what is the watch extension project? Is that a sibling folder to "Watch App" folder?Cipolin

© 2022 - 2024 — McMap. All rights reserved.