swiftswiftuiinfo.plistxcode16

I am running into a catch 22 with Info.plist settings in xcode 16


I am setting up an app that uses HealthKit and am experiencing a crash due to problems with my Info.plist file. This is the log:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'NSHealthUpdateUsageDescription must be set in the app's Info.plist in order to request write authorization for the following types: HKQuantityTypeIdentifierStepCount'
*** First throw call stack:
(0x1d31b250 0x1b58f160 0x1d3bab7c 0x3a4f02d0 0x3a4eff2c 0x3a4ef8f0 0xc5595c 0xc55594 0xc56c4c 0x43f23e38 0xc56b9c 0xc56c6c 0x24eb8614)
libc++abi: terminating due to uncaught exception of type NSException

I think the crash is happening because the NSHealthUpdateUsageDescription doesn't have a meaningful string in the Build settings. However, the Info.plist is generated by Xcode at runtime and I cannot modify (or delete) these entries manually, I cannot add new keys in the User-defined section because they already exist, nor do I think I can make a manual Info.plist because there are other settings in the automatically generated one I believe my app needs to run. Any help is appreciated!


Solution

  • To see the content of the Info.plist go to the Info tab and add something like Accessibility Bundle Name to it.

    The Info.plist will then appear by magic in the Xcode left panel, where you can Open As->Source Code....

    You can then manually add new items, or override the default settings, these are not displayed for some reason.

    For example:

     <key>NSHealthUpdateUsageDescription</key> 
          <string>health check</string>