Search code examples
iosswiftxcodeprovisioning-profilecode-signing-entitlements

Conflicting app identifiers after adding HealthKit to Apple Watch Extension


I was adding a watchOS target to my already existing iOS target. Everything worked fine until I added the HealthKit capabilities in the "Signing & Capability" Section of the watchapp.extension. Whereas everything worked fine with the iOS target, the watchapp extension complained after I added the respective capability and I received 3 errors. From which the first stated:

"Failed to register bundle identifier. The app identifier "[...].watchkitapp.watchkitextension" cannot be registered to your development team. Change your bundle identifier to a unique string to try again."

After adding the capability without details

After adding the capability with details

Things I tried so far and noticed are listed below:

  • the Xcode managed ("automatically signed") Provisioning Profile of the watchkitapp.watchkitextension lags one day behind the Provisioning Profile from the iOS target. Whereas this one misses the capability and 2 entitlements, the latter is up to date. This is also stated by the two other errors:

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

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

  • In the Apple Developer account I can find the iOS identifier and the watchapp identifier. However, the watchkitapp.watchkitextension identifier is missing and cannot be added manuelly, as it is already taken, thus not unique. I don't know how though.

  • Downloading the provisioning profiles manuelly did not do the job.

  • Removing and adding the watchapp target to the project did reproduce the same error.

  • The app is already running in the Store, so changing the identifier/bundle Id is not an option.

  • When I remove the healthKit capability, everything works fine. I can run it on my devices and even upload it to the store.

My literal guess is that the provisioning profile for the watchapp.extension is the root cause and that it is somehow attached to another team - which I don't know why. It lags one day behind the one for the iOS target and hasn't received the updated about the healthkit. The certificate in the provisioning profile is the same though as in the one concerning the iOS target. However, even starting from zero and readding the watchapp target did not help.


Solution

  • The watch app extension was registered with my free plan account under the same identifier and caused the conflict. Apple had to delete that identifier in order for it to be assigned to my 'real' developer account.

    Somehow I managed to register my watch app extension with the same initial bundle identifier as my parent app. However, rather than registering it with my real developer account I did so with my free plan account, hence the "Failed to register bundle identifier." error.

    Surprisingly my watch app (not the extension) was registered under my real account which bugs me, since they are both created at the same time when you create the watchOS target.

    The problem with that is, that as a free user you cannot look into the identifier registered under your account. You have to ask Apple to delete the identifiers for you. After that Xcode was creating a new provisioning profile.