20

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

r.izumita
  • 450
  • 1
  • 4
  • 13

4 Answers4

51

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>
Rahul Bansal
  • 1,382
  • 15
  • 22
29

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

Tim
  • 1,428
  • 19
  • 26
1

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

electronix384128
  • 6,625
  • 11
  • 45
  • 67
r.izumita
  • 450
  • 1
  • 4
  • 13
  • Yeah,sometimes the 3part may not suit iOS10 – 无夜之星辰 Sep 28 '16 at 09:25
  • Thanks, you solved my problem. If you just delete Leanplum.trackAllAppScreens() this line it works,either but probably you will not receive in-app notifications. – miletliyusuf Nov 03 '16 at 09:22
  • We tested with Swift 3 and Xcode 8 and we couldn't reproduce your issue. It seems its not related to Leanplum SDK and using the latest Xcode version resolves the issue. Please let us know otherwise ;) – electronix384128 Nov 10 '16 at 22:48
1

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

MAhipal Singh
  • 4,745
  • 1
  • 42
  • 57