缺少HealthKit权利 [英] Missing HealthKit Entitlement

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

问题描述

我正在尝试将HealthKit与正在构建的应用程序集成,并且我似乎已经成功为其添加了权利.我已经创建并下载了具有适当应用ID的配置文件,并且Xcode Capabilities选项卡中的HealthKit切换看起来不错:

I am trying to integrate HealthKit with an app I'm building, and I seem to have successfully added the entitlement for it. I've created and downloaded a provisioning profile with the appropriate app ID, and the HealthKit toggle in the Xcode Capabilities tab seems to look fine:

但是,当我运行该应用程序时,出现以下错误:

However, when I run the app, I get the following error:

HealthKit authorization denied!
Error Domain=com.apple.healthkit Code=4 "Missing com.apple.developer.healthkit entitlement." UserInfo={NSLocalizedDescription=Missing com.apple.developer.healthkit entitlement.}

这是一条奇怪的错误消息,因为Add the "HealthKit" entitlement to your App ID已被成功完成检出.

This is a strange error message to be getting since Add the "HealthKit" entitlement to your App ID is already checked off as successfully completed.

但是,一旦出现错误,检查的App ID权利将更改为:

However, once I get that error, the checked App ID entitlement changes to:

但是在我的开发者帐户的App ID中,App ID显示确实启用了HealthKit.

But in my App ID in my developer account, the App ID shows that HealthKit is indeed enabled.

它在我的配置文件中显示了相同的内容.

And it shows the same thing in my provisioning profile.

我只有一个应用程序ID和一个配置文件可供选择,因此不可能将它们混淆.

And I only have one App ID, and one provisioning profile to choose from, so it's impossible I'm getting them mixed up.

推荐答案

我现在对CloudKit的权利有一个非常类似的问题:(最终保存在最终的归档文件中.尽管通过了验证,但是...很奇怪.

I have a very similar problem with CloudKit entitlements now :( Works in Debug in Simulator and device, but not when built using distribution profile, entitlements just don't end up in the final archive. Passes validation though... odd.

您有没有解决这个问题?

Did you by any chance solve this?

如果没有,您仍然可以检查一些事情.

If not, there are a few things you could still check.

  1. 要确保您的Xcode不会混淆要使用的配置文件-转到偏好设置"->帐户"->查看详细信息"->右键单击一个配置文件->在Finder中显示". 现在,删除该文件夹中的所有配置文件.我们这样做是为了防止Xcode意外使用错误的配置文件.

  1. To make sure that your Xcode is not confused about which profile to use - go to Preferences -> Accounts -> View Details -> Right click on one of the profiles -> Show in Finder. Now delete all of the profiles in that folder. We are doing this so that Xcode can't accidentally use the wrong profile.

为确保Xcode可以找到最新的配置文件,我将再次重新生成配置文件,以防万一(删除并重新添加)为新名称.然后下载并双击. (通过Xcode下载有时可能会很不稳定)

To make sure that Xcode can find the most up to date profile, I would regenerate the profile again just in case (delete and re-add) with a new name. Then download and double click. (Downloading through Xcode can be flaky a times)

在这一点上,有必要检查一下配置文件是否确实包含正确的授权密钥.您可以运行"security cms -D -i profile_name.mobileprovision"并检查权利"部分.它应包含"com.apple.developer.healthkit"键

At this point it's worth checking that the provisioning profile does in fact contain the right entitlement keys. You can run 'security cms -D -i profile_name.mobileprovision' and check entitlements section. It should contain 'com.apple.developer.healthkit' key

现在,您可以转到Xcode并显式设置代码签名身份(类似于"iPhone Developer:..."或"iPhone Distribution:...",具体取决于您的测试方式) .之后,您可以显式设置Provisioning配置文件-Xcode应该能够找到它并向您显示配置文件的名称-它应该与您在第2步中使用的名称匹配.请确保正确设置了Debug/Release(再次取决于您如何进行测试).如果Xcode抱怨无法找到具有特定ID的配置文件->转到配置文件所在的文件夹并确保其存在,则文件名将以ID开头,然后重新启动Xcode,之后它应该可以工作.

Now you can go to Xcode and explicitly set code signing identity (will be something like 'iPhone Developer: ...' or 'iPhone Distribution: ...' - depending on how you are doing your testing). After that you can explicitly set the Provisioning profile - Xcode should be able to find it and show you the name of the profile - it should match the name you used in step 2. Make sure you set things correctly for Debug/Release (again depends how you are testing). If Xcode complains that it cannot find profile with specific id -> go to that folder where profiles were and make sure it's there, the filename will start with the id, then just restart Xcode, it should work after that.

如果您要构建实际的归档文件或ipas,最好知道这些软件包中包含哪些权利(您可以打开并检查它们;对于归档:归档文件(单击鼠标右键,显示软件包内容)->产品->应用程序->应用程序名称.app(右键单击,显示包内容)-> archived-expanded-entitlements.xcent(文本文件);对于ipa(类似):重命名为zip->解压缩->有效负载->应用程序名称.app-> archived-expanded-entitlements.cent

If you are building actual archives or ipas, it would be good to know what entitlements end up inside those packages (you can open them up and check; for archive: archive file (right click, show package contents) -> Products -> Applications -> app name.app (right click, show package contents) -> archived-expanded-entitlements.xcent (text file); for ipa (similarly): rename to zip -> unzip -> Payload -> app name.app -> archived-expanded-entitlements.cent

-----编辑------

----- EDIT ------

我已经解决了我的问题.我认为我的项目文件处于一种奇怪的状态,因为我在过去的某个时候重命名了这些东西,并且不得不手动更新项目文件中的某些条目.

I've fixed my problem. I think my project file was in a weird state because I renamed things at some point in the past and had to update some entries manually in the project file.

我知道构建过程的哪一步出错了.是ProcessProductPackaging步骤采用原始权利并生成了.xcent文件,该文件最终用于签名.

I knew which step of the build process was going wrong. It was the ProcessProductPackaging step that took original entitlements and generated the .xcent file that was eventually used for signing.

由于某种原因,对于Release配置,Xcode并不遵循我的权利文件的位置,而是仅使用了SDK中的默认模板,例如. /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk/Entitlements.plist

For some reason, for Release configuration, Xcode was not honouring the location of my entitlements file, instead it just used the default template from the SDK, eg. /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk/Entitlements.plist

我不知道为什么会这样,但是对于Debug配置来说一切似乎还可以.因此,我取消了Release配置,并使用不同的名称创建了一个新配置,之后构建过程开始获取我的权利文件.从项目文件diff中,仍然不清楚为什么以前不起作用.

I couldn't figure out why exactly, but things seemed to work ok for Debug configuration. So I nuked my Release config and created a new one with a different name, after that the build process started to pick up my entitlements file. From the project file diff it still wasn't obvious why things didn't work before.

这篇关于缺少HealthKit权利的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆