react-native-image-picker: App Crashes after photo selection (iOS 13)

Bug

  1. Click on Choose Photo (iOS Simulator (iOS 13))
  2. Select Photo
  3. App crashes

Is this possible a permissions issue? I’m able to select the photo, but then the app crashes immediately after that and console.log(response) logs undefined

Environment info

OS iOS 13

System
    OS: macOS 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
    Memory: 4.05 GB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 12.9.1 - /usr/local/bin/node
    npm: 6.10.2 - /usr/local/bin/npm
  SDKs:
    iOS SDK:
      Platforms: iOS 13.0, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
  IDEs:
    Xcode: 11.0/11A420a - /usr/bin/xcodebuild
  npmPackages:
    react: 16.8.6 => 16.8.6 
    react-native: 0.60.5 => 0.60.5 
  npmGlobalPackages:
    react-native-cli: 2.0.1
    react-native-git-upgrade: 0.2.7

Libraries:

    "react": "16.8.6",
    "react-native": "0.60.5",
    "react-native-image-picker": "^1.1.0",

Steps To Reproduce

  1. Click on Choose Photo (iOS Simulator)
  2. Select Photo
  3. App crashes

Reproducible sample code

  addPhoto = () => {
    try {
      // Image Picker
      ImagePicker.showImagePicker(response => {
        console.log(response);
      });
    }
    catch (error) {
      console.log(error);
    }
  }

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 30

Most upvoted comments

i am still facing this issue after adding these permission in info.list @sgimmai

@jefelewis here’s mine

<key>NSCameraUsageDescription</key>
<string>$(PRODUCT_NAME) would like to use your camera</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string></string>
<key>NSMicrophoneUsageDescription</key>
<string>$(PRODUCT_NAME) would like to use your microphone (for videos)</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>$(PRODUCT_NAME) would like to save photos to your photo gallery</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>$(PRODUCT_NAME) would like access to your photo gallery</string>

I resolved this issue successfully. You can add some value below to info.plist <key>NSPhotoLibraryUsageDescription</key> <string>$(PRODUCT_NAME) would like access to your photo gallery</string> <key>NSCameraUsageDescription</key> <string>$(PRODUCT_NAME) would like to use your camera</string> <key>NSPhotoLibraryAddUsageDescription</key> <string>$(PRODUCT_NAME) would like to save photos to your photo gallery</string> <key>NSMicrophoneUsageDescription</key> <string>$(PRODUCT_NAME) would like to use your microphone (for videos)</string>

+1, Not stale - still an issue

Adding the permissions for both iOS and Android fixed it for me.

Hello all,

As per above recommendation you have to do following:

  1. Open Info.plist located in ios/{NAME_OF_YOUR_PROJECT}/Info.plist

  2. Add following keys related to PhotoLibrary usage:

    <key>NSPhotoLibraryAddUsageDescription</key> <string>$(PRODUCT_NAME) would like to save photos to your photo gallery</string> <key>NSPhotoLibraryUsageDescription</key> <string>$(PRODUCT_NAME) would like access to your photo gallery</string> <key>NSLocationWhenInUseUsageDescription</key>

Example:

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>NSCameraUsageDescription</key> <string>$(PRODUCT_NAME) would like to use your camera</string> <key>NSMicrophoneUsageDescription</key> <string>$(PRODUCT_NAME) would like to use your microphone (for videos)</string> <key>NSPhotoLibraryAddUsageDescription</key> <string>$(PRODUCT_NAME) would like to save photos to your photo gallery</string> <key>NSPhotoLibraryUsageDescription</key> <string>$(PRODUCT_NAME) would like access to your photo gallery</string> </dict>

IOS 13, Iphone 11 simulator

  1. Save the file
  2. Re-run the react-native run-ios command or Run -> Build on Xcode
  3. Now you are good to go

BR, Zhi

If the app is crashing after choosing a photo from iOS simulator gallery, I suppose it is caused because is a high quality image and there is a limit… when my app crashes, this “error” appears in Xcode: libsystem_kernel.dylib`__abort_with_payload: Captura de Tela 2019-12-06 às 13 35 04

I don’t know if it makes sense…

I resolved this issue successfully. You can add some value below to info.plist NSPhotoLibraryUsageDescription $(PRODUCT_NAME) would like access to your photo gallery NSCameraUsageDescription $(PRODUCT_NAME) would like to use your camera NSPhotoLibraryAddUsageDescription $(PRODUCT_NAME) would like to save photos to your photo gallery NSMicrophoneUsageDescription $(PRODUCT_NAME) would like to use your microphone (for videos)

The app is still crashing after the photo selection and with the items added to info.plst as the following. Are you on iOS 13?

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>LastAccessedDate</key>
	<date>2019-09-23T06:56:55Z</date>
	<key>WorkspacePath</key>
	<string>/Users/jefflewis/Documents/Computer-Programming/Projects-Mobile-Apps/imagePickerTest/ios/imagePickerTest.xcworkspace</string>
	<key>NSPhotoLibraryUsageDescription</key>
	<string>$(PRODUCT_NAME) would like access to your photo gallery</string>
	<key>NSCameraUsageDescription</key>
	<string>$(PRODUCT_NAME) would like to use your camera</string>
	<key>NSPhotoLibraryAddUsageDescription</key>
	<string>$(PRODUCT_NAME) would like to save photos to your photo gallery</string>
	<key>NSMicrophoneUsageDescription</key>
	<string>$(PRODUCT_NAME) would like to use your microphone (for videos)</string>
</dict>
</plist>