I have a framework that uses
_healthStore requestAuthorizationToShareTypes:writeTypes readTypes:readTypes completion:^(BOOL success, NSError *error) {
When I include the framework into my iOS app and put the following in my app info.plist file
<key>NSHealthShareUsageDescription</key>
<string>Read heart rate monitor data.</string>
<key>NSHealthUpdateUsageDescription</key>
<string>Share workout data with other apps.</string>
everything works fine - not including those keys results in the following error:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'NSHealthShareUsageDescription must be set in the app's Info.plist in order to request read authorization.'
My problem is that when running the unit tests for the framework it crashes with the above error. I've put the keys in all of the info.plist files for the framework and for the test target but still get the crash.
Which plist file should the keys go into in order to run the test target?
(should also mention that I'm in the process of switching over to Swift3 - this is part of the project that is in Objective-C - prior to iOS10 and XCode 8 this all worked fine).
I've created a framework with appropriate unit test to show the problem: https://github.com/asensei/HKHealthStoreFrameworkUnitTestBug
You must add the NSHealthShareUsageDescription and NSHealthUpdateUsageDescription keys to the Info.plist file in your application. You do this by:
Clicking on the "Info.plist" file
Right clicking the screen and select add rows.
scroll to "Privacy - Health Share.. " and "Privacy - Health Update.. "
You have to add two descriptions NSHealthUpdateUsageDescription
and NSHealthShareUsageDescription
, and then give each of them a description. See screenshot below.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With