我在我的HealthKit Swift应用程序中添加了iOS代码,但我得到了一个错误:
/* 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")
}
}错误发生=错误Domain=com.apple.healthkit Code=4“缺少com.apple.developer.healthkit权限”。UserInfo=0x7fa748534b00 {NSLocalizedDescription=Missing com.apple.developer.healthkit权限.}
怎么才能解决这个问题呢?
发布于 2016-06-06 19:26:43
我花了3天的时间试图找出问题出在哪里。我通过这些步骤找到了解决方案:

我使用的是iOS 9.3.2和Xcode 7.3.1
发布于 2014-10-08 22:43:03
此错误是由于您没有向目标添加HealthKit权限这一事实。
{ProjectName}.entitlements文件和应用程序ID遵循这些步骤后,尝试再次运行您的应用程序。这一次它应该会起作用。
发布于 2015-02-21 04:02:07
以上两种答案都应先试一试。不过,如果
然后,通过选择目标并选择
生成设置->代码签名->配置文件
然后手动选择。
如果使用的是“自动选择”,则在调试中遇到以下错误:
https://stackoverflow.com/questions/25993314
复制相似问题