本文介绍了HealthKit错误:缺少com.apple.developer.healthkit授权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在iOS Swift应用中添加了HealthKit的代码,但出现错误:

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")
  }
}

如何解决这个问题?

推荐答案

我花了3天的时间来找出问题所在.我通过以下步骤找到了解决方案:

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

  1. 首先进入项目(如图中所示)
  2. 打开项目和目标列表
  3. 选择nameApp WatchKit扩展
  4. 转到功能"选项卡,在Health Kit中按,然后瞧……它对我有用.

我正在使用iOS 9.3.2和Xcode 7.3.1

I am using iOS 9.3.2 and Xcode 7.3.1

这篇关于HealthKit错误:缺少com.apple.developer.healthkit授权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 10:45