Asking for HealthKit permissions on the Apple Watch

Independent Watch App and HealthKit

In the development of my latest app which is an Independent Watch App that uses HealthKit, I ran into an issue with App Store Connect. App Store Connect will complain about missing Purpose Strings, that is the messages display to the user when access permission is asked for health information.

ITMS-90683: Missing Purpose String in Info.plist – Your app’s code references one or more APIs that access sensitive user data. The app’s Info.plist file should contain a NSHealthShareUsageDescription key with a user-facing purpose string explaining clearly and completely why your app needs the data. Starting Spring 2019, all apps submitted to the App Store that access user data are required to include a purpose string. If you’re using external libraries or SDKs, they may reference APIs that require a purpose string. While your app might not use these APIs, a purpose string is still required. You can contact the developer of the library or SDK and request they release a version of their code that doesn’t contain the APIs. Learn more (https://developer.apple.com/d
ocumentation/uikit/core_app/protecting_the_user_s_privacy
).


ITMS-90683: Missing Purpose String in Info.plist – Your app’s code references one or more APIs that access sensitive user data. The app’s Info.plist file should contain a NSHealthUpdateUsageDescriptio
n key with a user-facing purpose string explaining clearly and completely why your app needs the data. Starting Spring 2019, all apps submitted to the App Store that access user data are required to include a purpose string. If you’re using external libraries or SDKs, they may reference APIs that require a purpose string. While your app might not use these APIs, a purpose string is still required. You can contact the developer of the library or SDK and request they release a version of their code that doesn’t contain the APIs. Learn more (https://developer.apple.com/d
ocumentation/uikit/core_app/protecting_the_user_s_privacy
).

This is regardless of whether the Property List in the Watch App Extension includes these properties.

The Resolution

To resolve this issue, create a new Property List with no target set in your project at the root:

Inside that Property List add (or copy) the required HealthKit Property Strings to your new Property List file.

In short, these properties should be the only required properties in your file. Lastly, set this Property List file as the property list file of your app container target:

  1. Click on the Project File in the Navigator on the right.
  2. Select the App Container target.
    This should be obvious since the target does not come with a Property List file on initial creation in Xcode.
  3. Go to the Build Setting tab on the top.
  4. Search for Info.plist File
  5. In the field value enter the name of the newly created Info.plist file with your HealthKit Privacy strings set.

Now go ahead and archive and distribute your app to App Store Connect from the organizer as usual. App Store should be happy moving forward.

In Summary…

  • App Store Connect requires both your Apple Watch App Extension and your App Watch App Container to contain an Info.plist file with NSHealthUpdateUsageDescription and NSHealthShareUsageDescription strings set.
  • To fix this, create a new Info.plist file with those settings set for your App Container.
  • The new Info.plist is not to be included in your App Container but rather set as your App Container’s Info.plist file in Build Settings.

Perhaps this will be fixed in the Independent Apple Watch App template in the future or in App Store Connect but for now you can easily publish your Independent Watch App to the TestFlight and the App Store.

HealthKit – Getting Started – HKObjectType and Authorization

HealthKit is the most important API when it comes to building health, fitness and workout apps. HealthKit also has many intricacies and details which need introduction when getting started.

The data structures encourage precision while having the flexibility to store a variety of values. The way it asks users give app access HealthKit will probably be similar with many iOS developers. HealthKit follows many patterns in other iOS APIs such as Core Location or Core Data. At the same time it uses newer programming techniques and newer technology.

Continue reading →