I'm writing a Mac app using Catalyst, that uses HomeKit to control some accessories.
When running from Xcode there are no issues, it works fine, however when running any other way – directly from Finder, after distributing on TestFlight, or even during App Store Review, the app crashes as soon as it attempts to use HomeKit.
The crash log is very clear, it says:
This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSHomeKitUsageDescription key with a string value explaining to the user how the app uses this data.
The problem is that I do have NSHomeKitUsageDescription in my Info.plist. It's always been there since I enabled HomeKit.
So far I've tried a bunch of different resolutions:
- I've double and tripled checked the value in the Info.plist, there is a non-empty, reasonable sentence description, against the key
NSHomeKitUsageDescription, which is shown as "Privacy - HomeKit Usage Description". - I've switched from an xcodeproj embedded generated Info.plist to a real file-on-disk Info.plist and back again (all worked correctly, except for this).
- I've switched from managed certificates and profiles to manual certificates and profiles and back again (as far as I can tell from research, managed certs should work fine)
- I've checked that the Info.plist in the app bundle does indeed contain the correct key.
So far, no progress, it just always crashes with the same result. Annoyingly because the crash error message is so obvious all the search results I've found here, on Google, or on the Apple dev forums are saying "just add the key", which I've done with no success.
One potentially complicating factors that could be involved, my app contains an embedded macOS-only framework that it uses to access AppKit. I used the technique from an open-source app that apparently successfully uses HomeKit, so I don't expect that to be causing the issue. I've also tried adding the key to the framework's info.plist as well but to no effect. Disabling the framework doesn't help either. I can add more detail about this if necessary, but I don't think it's the cause of the issue.
Updates to clarify things:
- Already accounting for the bug in Xcode 14 that misses HomeKit entitlements.
- Reproducible on macOS Ventura and on Xcode Server with Monterey.
- Tried re-signing the framework after embedding in the app.