XCode signing says NSHomeKitUsageDescription not supplied, how do I do that?

I get the error:

"Provisioning profile "iOS Team Provisioning Profile: ***.***.homekitexporter" doesn't include the NSHomeKitUsageDescription entitlement."

I have HomeKit enabled in the .entitlements file and I added the NSHomeKitUsageDescription to that also. I looked at the profile under my development account and I can see the HomeKit entitlement but I see nowhere to add the usage description key and string other than in the .entitlements file.

I also tried adding the key and string to the Custom IOS Properties for my Target APP but that didn't work either.

What am I missing?

Replies

Usage description keys such as NSHomeKitUsageDescription go in your app’s Info.plist file. See here for examples of others that work the same way.

Wherever that error message is coming from, it’s not well-written. Consider submitting a Feedback about that.

True but the new XCode projects do not include an Info.plist file, it is generated automagically during the build process from the .entitlements file and other things. I even tried adding an Info.plist but got an error from having duplicate files. I have submitted a bug report, a support request, and am downloading the latest XCode beta to see if that helps.

Go to your target settings and select the Info tab. You’ll add your setting in the Custom iOS Target Properties section. In this screen the key name is rendered as Privacy - HomeKit Usage Description.

Under the hood Xcode stores it as a user-defined build setting with a key of INFOPLIST_KEY_NSHomeKitUsageDescription and then copies it into the final Info.plist file at build time. You can see this key (after you add it) in the Build Settings list, but this is really more of an implementation detail.

Did that, doesn’t fix it. The error refers to the Provisioning Profile and there doesn’t seem to be a way to add the key there. Not that I think it belongs there; as you say, it belongs in Info.plist. I think it’s a signing bug and I have opened a support request with Apple.

I looked at the profile under my development account and I can see the HomeKit entitlement

Do you mean you see that capability enabled in your App ID, or you mean you have a manually-created provisioning profile and see it there? Is the app using a manual provisioning profile or one that Xcode manages for you? (The kind not listed in your account online.)

I have HomeKit enabled in the .entitlements file

Did you add the HomeKit capability via Xcode’s Signing & Capabilities screen, or by manually editing the entitlement file? Just trying to figure out what may be different from the standard automated behavior, if any.

I am using Automatic Signing. That, actually, is where the problem is.

Under my Target Capabilities I added (+ button) Homekit. That added the key for Homekit: YES to the .entitlements file automagically as well as added HomeKit as a Framework. It did not add any NSHomeKitUsageDescription key anywhere. I have added that manually to the Info tab under Custom iOS Target Properties. That should propagate to the Info.plist file and, in fact, it does do that.

The problem is that the Automatic Signing is looking for NSHomeKitUsageDescription in the Provisioning Profile. It doesn’t exist in there and has no purpose being in there, it is not relevant at that time in the build process. And, additionally, there is no way to actually put it into the Provisioning Profile.

Wait, is the error message from just trying to build in Xcode, or is it when trying to upload an archived build to App Store Connect? I assumed the latter since it does sound like the kind of messages you can get upon a failed upload.

Either way, does the issue repro if you create a new empty app and perform the steps to add HomeKit? And if it’s when trying to upload, does the organizer’s Validate feature produce the same error, or does Validate run clean and it fails only when trying a real upload?

The error is from the build during the Automatic Signing. Actually that process runs even without any Build requested.

It appears that it is due to my own ignorance as I have just gotten it to work with bit of help from Apple. I had originally tried putting the UsageDescription into the .entitlements file. That was the cause of all the difficulty. Once I removed it from there and ensured it was in the Info section the signing completes successfully. Having it in both places caused an error.

Sigh ... why isn't it ever easy?

Bill W