Get your standalone HealthKit Watch app through App Store Connect & Review

Dan Beech
4 min readFeb 12, 2021
Photo by Karsten Winegeart on Unsplash

Recently I published a standalone Watch app to the App Store. I designed the app, I coded the functionality, I added the relevant HealthKit permissions to the info.plist, and I followed the steps to send the build over to App Store Connect for review. Job done 👏 … Or so I thought.
Xcode kicked the app back to me with upload errors telling me that I hadn’t requested the permissions I had already requested 🤔
This one was a bit confusing so I thought I’d write my first Medium article to let everybody else know how I got past it and got my app published!

Photo by Taras Shypka on Unsplash

I’m going to start from the beginning for those who haven’t started their implementation yet, but feel free to skip ahead to get what you need.

First of all, you need to initialise your HealthStore.

And then you will need to request authorisation.

After the initial set up is done you will want to start your heart rate query and then process the values. In my process function I have saved the result of the processing to a variable called heartRateBPMValue as an int to use in the UI of my project.

Finally to display the heart rate to the user you can do something like the following code in SwiftUI.

This code isn’t meant to be a full working project, it’s just some functions I’ve pasted from my own project that will help you on your way to setting up and using HealthKit and heart rate monitoring. The Apple documentation has much more information about other types of workouts and what you can monitor, so go and check those out to make sure you fully understand it.

Now that the code is done and your project is working, what permissions do you need to request? For the above example, using heart rate monitoring, you would need to add two entries to your WatchKit Extension info.plist:

  • NSHealthShareUsageDescription
  • NSHealthUpdateUsageDescription

You should provide a string for these values explaining why you need to access this information and let the user know what you will use the information for, e.g. “The app needs access to your Health data to track heart rate during workouts”. This is the message that will be displayed to users when the app first asks them for permission to access their data, so ensure that the users know what you are doing or Apple may reject your app and ask for a more descriptive message.

You should also head into your ‘App_Name WatchKit Extension.entitlements’ file and add HealthKit to the entitlements, and add any HealthKit Capabilities that you need.

So now that the code is done, the app works, it requests the permissions when you run it on a new device or simulator, and it tracks the heart rate properly. It’s time to send the app off to the App Store?
Nope, not yet! It will still be rejected at this stage, so let’s fix that.

Photo by Michał Kubalczyk on Unsplash

Create a new group at the same level in the folder structure as your Watchkit Extension. Name this the name of your app. Now we need to create a new info.plist inside this folder. Don’t delete your other files, we still need those to actually ask for permissions on the Watch app, this new file is to satisfy the App Store review process because standalone Watch apps are submitted as iOS apps and something in the review process means that the permissions on your WatchKit Extension won’t be enough to satisfy the Review process.

Remember those permissions we asked for earlier? You will need to add those to this info.plist too, as well as the original. You can copy and paste the same strings you used in the original file.
After you’ve added those permissions you should uncheck all the targets in the ‘Target Membership’ in the Utilities (right-hand side menu in Xcode).
Then click on the ‘.xcodeproj’ and select the target that says the name of your app in the targets list (not the WatchKit App, or WatchKit Extension). Go to the Build Settings and search for ‘info.plist’ for the entry named ‘Info.plist File’ you should enter the location of the file we added. If you put it in a folder with your app name as I mentioned earlier, you should enter ‘AppName/Info.plist’.

Now you can build your app and send it to App Store Connect and it should make it through the review process without flagging up those issues about permissions! 👏👏

If you are submitting the app for review make sure that your app description declares that your app integrates with the Apple Health application and why it does that, or they will reject it based on metadata, just to save you some extra time!

Thanks for reading, good luck with your apps!

--

--

Dan Beech

Flutter Engineer @ Bloom Money 🌱. Liverpool, UK. Enjoy mobile development with a focus on UI/UX implementation 🧑‍💻