Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIImagePickerController crashes on iOS10

On presenting UIImagePickerController with photo library source on iOS10, my app crashes.

On iOS10 with camera source and on iOS9 with photo library and camera sources, the app does not crash.

The app is written in Swift 2.2 and built by Xcode 7.3.1.

Why does the crash occur?

let imagePicker = UIImagePickerController()
imagePicker.sourceType = .PhotoLibrary
imagePicker.allowsEditing = true
imagePicker.delegate = self
self.presentViewController(imagePicker, animated: true, completion: nil)

stack trace

like image 630
r.izumita Avatar asked Sep 21 '16 08:09

r.izumita


4 Answers

Rahul's answer is perfect. If you prefer to add it straight into your plist rather than via the plist's source code then just do the following. plist additions

like image 21
Tim Avatar answered Nov 09 '22 19:11

Tim


You may need to put the NSCameraUsageDescription (if your app uses the Camera) and NSPhotoLibraryUsageDescription (if your app uses the Photo Library) in your plist. Like below,

<key>NSCameraUsageDescription</key>
<string>$(PRODUCT_NAME) needs access to use your camera</string>

<key>NSPhotoLibraryUsageDescription</key>
<string>$(PRODUCT_NAME) needs access to use your photo library</string>
like image 153
Rahul Bansal Avatar answered Nov 09 '22 17:11

Rahul Bansal


I solved the crash by updating to the latest Xcode version. The problem has been discussed here as well: https://github.com/Leanplum/Leanplum-iOS-SDK/issues/12

like image 1
r.izumita Avatar answered Nov 09 '22 19:11

r.izumita


permission keys in plist for permission For Camera (also need Microphone permission) and PhotoLibrary

<key>NSCameraUsageDescription</key>

${PRODUCT_NAME} Camera Usage

<key>NSMicrophoneUsageDescription</key>

${PRODUCT_NAME} Microphone Usage

<key>NSPhotoLibraryUsageDescription</key>

${PRODUCT_NAME} PhotoLibrary Usage

like image 1
MAhipal Singh Avatar answered Nov 09 '22 18:11

MAhipal Singh