use*_*367 4 swift xcode6 ios8 healthkit
我在我的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")
}
}
Run Code Online (Sandbox Code Playgroud)
发生错误=错误域= com.apple.healthkit代码= 4"缺少com.apple.developer.healthkit权利." UserInfo = 0x7fa748534b00 {NSLocalizedDescription =缺少com.apple.developer.healthkit权利.}
怎么解决这个?
谢谢!
Jor*_*nez 16
我花了3天时间试图找出问题所在.我找到了这些步骤的解决方案:
我使用的是iOS 9.3.2和Xcode 7.3.1
小智 10
应首先尝试上述两个答案.但是如果
然后尝试通过选择目标并转到,强制构建使用该特定的配置文件
构建设置 - >代码签名 - >配置文件
并手动选择它.
如果使用"自动选择",我遇到了在调试中遇到上述错误的情况
该错误是由于您尚未将HealthKit权利添加到目标.
1)转到Xcode中的项目设置.2)从那里,导航到"功能"选项卡.3)向下滚动,直到看到"HealthKit"并将开关拨到打开状态.4)Xcode现在将为您的Info.plist,您的{ProjectName} .entitlements文件和iTunes Connect上的App ID添加HealthKit权利
完成以下步骤后,请尝试再次运行您的应用.这一次它应该工作.
在 Capabilities 中激活 Health kit

如果还是不行
check:
| 归档时间: |
|
| 查看次数: |
12734 次 |
| 最近记录: |