This app has crashed because it attempted to access privacy-sensitive data without a usage

升级 iOS 10 后,在 xcode 运行项目时会常常出现 如下的提示,导致应用崩溃:
This app has crashed because it attempted to access privacy-sensitive data without a usage description.

别急这个是由于权限造成的

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

相册权限

如上提示的 The app’s Info.plist must contain an NSPhotoLibraryAddUsageDescription … 也就是在 iOS 中向相册中保存图片时,需要向系统申请访问相册的权限

 ///保存 Image 到系统相册中
 UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);

只需要在你 xcode 工程目录下的 info.plist 添加权限申请描述文件就如下:

    <key>NSCameraUsageDescription</key>
    <string>请允许APP访问您的相机</string>
    <key>NSPhotoLibraryAddUsageDescription</key>
    <string>请允许APP保存图片到相册</string>
    <key>NSPhotoLibraryUsageDescription</key>
    <string>请允许APP访问您的相册</string>

猜你喜欢

转载自blog.csdn.net/zl18603543572/article/details/108543146