我有一个应用程序,我正在更新到 Xcode 8.2.1。以前,对相机和照片库的访问工作正常。但是现在应用程序崩溃并显示以下消息:
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.
堆栈溢出上的许多帖子只是说"添加NSPhotoLibraryUsageDescription
密钥"到您的info.plist
。
但是我做过这样的事情!我的应用程序仍然崩溃!
我的info.plist
文件:
<key>NSLocationWhenInUseUsageDescription</key>
<string>Permet à l'application de connaitre l'emplacement de vos posts</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>$(PRODUCT_NAME) uses photos</string>
<key>NSCameraUsageDescription</key>
<string>$(PRODUCT_NAME) uses camera</string>
<key>CFBundleDevelopmentRegion</key>
该代码主要基于苹果示例...
- (IBAction)showImagePickerForPhotoPicker:(id)sender
{
[self showImagePickerForSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
}
- (void)showImagePickerForSourceType:(UIImagePickerControllerSourceType)sourceType
{
// ...
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
imagePickerController.sourceType = sourceType;
imagePickerController.delegate = self;
if (sourceType == UIImagePickerControllerSourceTypeCamera)
{
// ..
}
self.imagePickerController = imagePickerController;
[self presentViewController:self.imagePickerController animated:YES completion:nil];
}
好吧,我真的被困住了...也许是项目配置问题?
我很
抱歉,但这是我的错,在迁移时,我对info.plist文件造成了一些混乱。