iOS – 应用程序崩溃是因为它试图在没有使用说明的情况下访问隐私敏感数据

我收到以下错误:

[access] This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSPhotoLibraryUsageDescription key with a string value explaining to the user how the app uses this data.

你知道怎么解决这个问题吗?

这些是在项目的plist中设置的。 您可以通过导航到目标信息检查器并展开“自定义iOS目标属性”部分来添加/删除这些内容。 例如,我的项目中的一个条目是:

 Privacy - Camera Usage Description Allows user to capture a photo or video to upload to their family circle 

你可以看到这看起来如何:

项目检查员的例子

您需要转到Info.plist,添加新行并将NSPhotoLibraryUsageDescription粘贴到键列中。 然后在值列中提供有关您需要访问用户照片库的原因的说明。 如果您打算使用设备的相机,请使用NSCameraUsageDescription重复相同的步骤。