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>NSCameraUsageDescriptionkey>
    <string>请允许APP访问您的相机string>
    <key>NSPhotoLibraryAddUsageDescriptionkey>
    <string>请允许APP保存图片到相册string>
    <key>NSPhotoLibraryUsageDescriptionkey>
    <string>请允许APP访问您的相册string>

你可能感兴趣的:(ios开发中的点滴积累)