Bug 21781 - HealthKit entitlement not being recognised at runtime despite being correctly configured
Summary: HealthKit entitlement not being recognised at runtime despite being correctly...
Status: RESOLVED DUPLICATE of bug 20448
Alias: None
Product: iOS
Classification: Xamarin
Component: Pre-release ()
Version: 7.9.2.x
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2014-08-02 04:03 UTC by RichardH
Modified: 2014-08-26 22:35 UTC (History)
7 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description RichardH 2014-08-02 04:03:37 UTC
This bug is outlined in my forum post and was confirmed today by Larry O'Brien who wrote the HealthKit blog post featured on the Xamarin site.

See this link:


Still present in (Enterprise Edition)
Comment 1 Sebastien Pouliot 2014-08-04 10:17:10 UTC
In general the permission checks are not something under Xamarin's control. They are part of the (Apple supplied) tooling and/or are OS runtime checks.

Those checks tend to change during the previews - so things that worked in an old beta might need to be updated (and Apple docs on HealthKit are still very limited).

> Authorization error: Missing com.apple.developer.healthkit entitlement.
> when building and running the app.

That's not clear. If you're running the application then it built without error, right ?

Also please include all versions information* (not just XI) and the iOS version of your device(s). I assume beta 4 (based on the date) but need to be sure.

* The easiest way to get exact version information is to use the "Xamarin Studio" menu, "About Xamarin Studio" item, "Show Details" button and copy/paste the version informations (you can use the "Copy Information" button).
Comment 2 RichardH 2014-08-04 10:26:43 UTC
>Those checks tend to change during the previews - so things that worked in an old beta might need to be updated

Yes, that's why I'm notifying you.

>That's not clear. If you're running the application then it built without error, right ?

Yes, it's a runtime error.  The Entitlements.plist file was created by Xamarin Studio (File>Add File) and the correct key/value added, but the entitlement is not being recognised at runtime.  I'm guessing it's a problem with Xamarin and Beta 4, because it worked ok in Beta 2.

Device is an iPhone 5C running iOS 8.0 (12A4331d)

Xcode 6.0 Developer Preview Beta 4.

I'm checking the authorisation with:

            var hks = new HKHealthStore ();
            hks.RequestAuthorizationToShare (new NSSet (new [] { tempQuantityType }), new NSSet (), (success, error) => {
                Console.WriteLine ("Authorized:" + success);
                if (error != null) {
                    Console.WriteLine ("Authorization error: " + error);
Comment 3 Larry O'Brien 2014-08-05 13:12:15 UTC
I can confirm that this behavior changed sometime after beta 2 and continues with beta 5. I haven't been able to solve the problem, but I know that one thing that has changed is that now one has to add a "healthkit" string entry to info.plist for the UIRequiredDeviceCapabilities key.
Comment 4 Sebastien Pouliot 2014-08-06 14:36:06 UTC
I'll have a look once the beta 5 bindings are completed.
Comment 5 Hum 2014-08-12 04:07:15 UTC
This bug has solved?
Comment 6 RichardH 2014-08-12 04:50:30 UTC
Not in the current public alpha, no.
Comment 7 Hum 2014-08-13 02:15:24 UTC
iOS 8 beta 6 will publish this friday,maybe Apple had solved this bug
Comment 8 Larry O'Brien 2014-08-19 18:27:31 UTC
I have got my solution up and running on beta 6. The (embarrassingly simple) solution is that you get that entitlements message when you run the app on the simulator but on a device, all goes well.
Comment 9 RichardH 2014-08-19 18:41:12 UTC
I think that's more likely to be a Beta 6 thing than a device thing.  It wouldn't work on either in Beta 5.  I've seen a number of reports in the Apple dev forums complaining of the same problem in native apps, so perhaps it was Apple's issue all along.
Comment 10 Hum 2014-08-19 23:10:30 UTC
How does Larry solve this bug?Can you tell us clearly?Thank you
Comment 11 Alex Soto [MSFT] 2014-08-19 23:25:02 UTC

It seems that Apple now requires entitlements to be linked in simulator builds

So here is a workaround to get them working on Simulator builds

1. Build your app for Device configuration 
2. Copy your **AppName.xcent**[1] located in bin/iPhone/<Debug|Release>/AppName.xcent to your project root dir
3. Add this to your "Additional mtouch arguments" inside your project settings on Simulator config [2]

-gcc_flags="-Xlinker -sectcreate -Xlinker __TEXT -Xlinker __entitlements -Xlinker ${ProjectDir}/AppName.xcent"     
                                                                                                    [1] ^^^

4. Deploy to simulator and enjoy :)

This will be done automatically in a future release of Xamarin.iOS

[1]: Make sure to replace AppName.xcent with the actual name of your scent file
[2]: http://www.screencast.com/t/8XyOCK1WU8i
Comment 13 RichardH 2014-08-20 03:05:59 UTC
Excellent - thanks for the information Alex.
Comment 14 Hum 2014-08-20 05:31:27 UTC
Excuse me,how can I find the **AppName.xcent** and where do I find the "Additional mtouch arguments",I can't find project options in Xcode.Thank you
Comment 15 Alex Soto [MSFT] 2014-08-20 11:49:48 UTC

These are instructions for *Xamarin Studio* not for Xcode that said you can find your xcent file in the intermediate files generated by Xcode. 

Comment 16 Hum 2014-08-20 21:29:52 UTC

Thank you,Alex,can this bug be solved just by Xcode?

Comment 17 Alex Soto [MSFT] 2014-08-20 21:37:05 UTC

Xcode6 did not present any issues to me running the Fit sample that Apple ships. I did not test further.

Comment 18 Sebastien Pouliot 2014-08-26 22:35:10 UTC
There's already a bug report for the (UI) feature.

*** This bug has been marked as a duplicate of bug 20448 ***