gpt4 book ai didi

swift - HealthKit 错误 : Missing com. apple.developer.healthkit 权利

转载 作者:搜寻专家 更新时间:2023-10-31 08:09:09 26 4
gpt4 key购买 nike

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

/* 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 "Missingcom.apple.developer.healthkit entitlement." UserInfo=0x7fa748534b00{NSLocalizedDescription=Missing com.apple.developer.healthkitentitlement.}

如何解决这个问题?

最佳答案

我花了 3 天时间试图找出问题所在。我通过这些步骤找到了解决方案:

enter image description here

  1. 首先进入项目(如图所示)
  2. 开放项目和目标列表
  3. 选择 nameApp WatchKit Extension
  4. 转到 Capabilities 选项卡,在 Health Kit 中按下,瞧……它对我有用。

我正在使用 iOS 9.3.2 和 Xcode 7.3.1

关于swift - HealthKit 错误 : Missing com. apple.developer.healthkit 权利,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25993314/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com