Search code examples
iosxcodexcode14

Entitlements for multiplatform applications in Xcode 14


When creating a Multiplatform Application prior to Xcode 14, Xcode would create a separate Entitlements-file for each target. Now, with Xcode 14, all targets use the same Entitlements file by default.

After adding the HealthKit capability to an Xcode 14 project and populating the "Privacy - Health Update Usage Description" Key with a string in Info.plist, then prompting a HealthKit authorization request, the screen asking the user to agree to the App using HealthKit data does not pop up. Moreover, the following error is printed in the console: Health request display failed: Missing application-identifier entitlement.

In an effort to fix this problem, I edited the Entitlements file manually to look like this: Entitlements file

Adding the application-identifier entitlement to the Entitlements file manually fixes the issue, however, as the same Entitlements file is also used by the macOS target, Xcode fails to automatically sign the app for macOS and gives the following error:

Provisioning profile "Mac Team Provisioning Profile: com.xx.xx" doesn't include the application-identifier entitlement.

Here you can see the error given in Signing & Capabilities: Signing & Capabilities Xcode screen with error message

What is the correct approach here? Should I manually create a second Entitlements file and separate them? If so, how would this be done? Or is there something else I'm missing?

Any help would be greatly appreciated.


Solution

  • Testing on a real device, without manually editing the entitlements file, the error disappears and the HealthKit permission request is shown appropriately. Therefore, I believe the behavior above is just a Xcode/Simulator bug in the current beta.