0

I am trying to add HealthKit to my watchOS app (with companion app).

By default when you add a watchOS the bundle identifier is .watchkitapp

Once I add HealthKit to the Signing & Capabilities tab on my watch app target, when i try to deploy to my device (not simulator) the build fails with the errors:

Failed to register bundle identifier: The app identifier ".watchkitapp" cannot be registered to your development team because it is not available. Change your bundle identifier to a unique string to try again.

Provisioning profile "iOS Team Provisioning Profile: *" doesn't include the com.apple.developer.healthkit and com.apple.developer.healthkit.access entitlements.

Provisioning profile "iOS Team Provisioning Profile: *" doesn't support the HealthKit capability.

I've tried changing the bundle identifier to my ios app's bundle identifier followed by .watchkitapp com.companyname.appname.watchkitapp, but when i build the build initially works but then gives an pop up with an install error

This app contains a WatchKit app with an invalid bundle identifier. The bundle identifier of a WatchKit app must have a prefix consisting of the companion app's bundle identifier, followed by a '.'.

I've tried cleaning my build folder, restarting xcode and my devices but nothing helps

Nilsymbol
  • 515
  • 1
  • 9
  • 25
  • Does this answer your question? [How to set Bundle Ids, App Identifiers and Provisioning Profiles to publish a WatchOs App made with SwiftUI and XCode?](https://stackoverflow.com/questions/66984050/how-to-set-bundle-ids-app-identifiers-and-provisioning-profiles-to-publish-a-wa) – lorem ipsum Nov 26 '22 at 12:57
  • Unfortunately no, I am following the correct naming scheme for watch apps – Nilsymbol Nov 26 '22 at 13:46
  • The problem is your app is using the wildcard provisioning profile for your team `*` and that provisioning profile doesn't include the HealthKit entitlement. It looks like it failed to create a specific provisioning profile because somewhere you have the bundle identifier `.watchkitapp` instead of `main.app.identifier.watchkitapp`. – Paulw11 Nov 26 '22 at 19:46
  • You need to double check everything and use "automatically manage signing" – Paulw11 Nov 26 '22 at 19:55
  • I have turned on "automatically manage signing". It looks to me it's a xcode 14 issue, where this is the default bundle id when creating a watch app. Please let me know if this isn't the behavior for you – Nilsymbol Nov 26 '22 at 22:36
  • I get `.watchkitapp` as the default bundle id and you need to change it. The fact that it then says you have an invalid bundle identifier suggests you got the prefix wrong. Try `main.app.identifier.watch.watchkitapp` – Paulw11 Nov 27 '22 at 00:08
  • I had this same problem day (https://stackoverflow.com/questions/73500469/watchkit-2-0-apps-bundle-id-person-bundle-ropes-watchkitapp-is-not-prefixed-by) and try as I might, the answer from Google and linked SO didn't really help. What did happen was somehow, I played around w/ "automatically manage signing" and somehow something happened and it worked. (That took a few hours of my life!) – app4g Nov 27 '22 at 06:36

0 Answers0