HealthKit icon indicating copy to clipboard operation
HealthKit copied to clipboard

Use hooks to add HealthKit entitlement

Open sgilroy opened this issue 9 years ago • 2 comments
trafficstars

The readme for this plugin instructs the developer to manually add the HealthKit entitlement when adding the plugin.

Make sure your app id has the 'HealthKit' entitlement when this plugin is installed (see iOS dev center).

For my app, we clean and rebuild the cordova platforms every time we build, so this means that we have to manually go into Xcode and add the HealthKit entitlement each time, which is time consuming and error prone.

As an example, it looks like the cordova-universal-links-plugin adds the entitlements it needs via hooks: https://github.com/nordnet/cordova-universal-links-plugin/tree/master/hooks

Note that the HealthKit plugin.xml file does include the framework

<framework src="HealthKit.framework" weak="true" />

However, I believe the entitlement is not added automatically (despite this comment: https://github.com/Telerik-Verified-Plugins/HealthKit/issues/15#issuecomment-76390169).

sgilroy avatar Oct 30 '16 22:10 sgilroy

We were able to do this sort of automatically by upgrading to cordova-ios 4.3, which ensures that the xcode project gets an entitlement file. We then used this post-prepare hook to add the capability:

#!/bin/bash PLIST=platforms/ios/*/Entitlements-Debug.plist cat << EOF | Add :com.apple.developer.healthkit bool YES EOF while read line do /usr/libexec/PlistBuddy -c "$line" $PLIST done

true

This adds the capability to the plist file (you'd have to do the same for Release). Still it would be great if the plugin does this automatically.

ijansch avatar Nov 17 '16 09:11 ijansch

I am also having this same issue.

rupalpatel0008 avatar Nov 28 '16 08:11 rupalpatel0008