Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HealthKit error: Missing com.apple.developer.healthkit entitlement

I'm adding code for HealthKit in my iOS Swift app, but I'm getting an error:

/* Ask for permission to access the health store */
override func viewDidAppear(animated: Bool) {
  super.viewDidAppear(animated)
  
  if HKHealthStore.isHealthDataAvailable(){
    
    healthStore.requestAuthorizationToShareTypes(typesToShare,
      readTypes: typesToRead,
      completion: {(succeeded: Bool, error: NSError!) in
        
        if succeeded && error == nil{
          println("Successfully received authorization")
        } else {
          if let theError = error{
            println("Error occurred = \(theError)")
          }
        }
      })

  } else {
    println("Health data is not available")
  }    
}

Error occurred = Error Domain=com.apple.healthkit Code=4 "Missing com.apple.developer.healthkit entitlement." UserInfo=0x7fa748534b00 {NSLocalizedDescription=Missing com.apple.developer.healthkit entitlement.}

How can solve this?

like image 219
user3739367 Avatar asked Sep 23 '14 10:09

user3739367


People also ask

How do I add entitlement to HealthKit?

To add this entitlement to your app, first enable the HealthKit capability in Xcode, and then check any values that you want to add to the HealthKit Capabilities Entitlement. Only add values for data types that your app needs to access. App Review may reject apps that don't use the data appropriately.

How do I enable Apple HealthKit?

Enable HealthKitIn Xcode, select the project and add the HealthKit capability. Only select the Clinical Health Records checkbox if your app needs to access the user's clinical records. App Review may reject apps that enable the Clinical Health Records capability if the app doesn't actually use the health record data.

Where is the HealthKit on Iphone?

You'll tap "Signing & Capabilities" and hit that "+ Capability" button. You'll type in "HealthKit" and right then and there you'll add the HealthKit framework into your application, which will allow you to retrieve and store users' health information.

How do I enable HealthKit in Xcode?

Before you can use HealthKit, you must enable the HealthKit capabilities for your app. In Xcode, select the project and add the HealthKit capability. Only select the Clinical Health Records checkbox if your app needs to access the user’s clinical records.

How does Apple’s HealthKit work?

With the user’s permission, apps communicate with the HealthKit store to access and share this data. Creating a complete, personalized health and fitness experience includes a variety of tasks:

How do I remove HealthKit from my App?

If HealthKit isn’t required for the correct operation of your app, delete the healthkit entry from the Required device capabilities array. For projects created using Xcode 13 or later, delete this entry from the Target Properties list on the app’s Info tab. For projects created with Xcode 12 or earlier, delete it from the apps Info.plist file.

Why is HealthKit not available on my Device?

If HealthKit isn’t available on the device (for example, on an iPad), other HealthKit methods fail with an errorHealthDataUnavailable error. If HealthKit is restricted (for example, in an enterprise environment), the methods fail with an errorHealthDataRestricted error.


1 Answers

I spent 3 days trying to figure out what was the problem. I found the solution with those steps:

enter image description here

  1. First go to the project (As I show in the image)
  2. Open projects and target lists
  3. Select nameApp WatchKit Extension
  4. Go to Capabilities tab, press on in Health Kit and voila... it is working for me.

I am using iOS 9.3.2 and Xcode 7.3.1

like image 185
Jorge Luis Jiménez Avatar answered Sep 17 '22 19:09

Jorge Luis Jiménez