react-native-image-picker: iOS 13 not working?

Bug

Only on iOS 13 does not work and gives me this error, iOS 12 works properly.

Environment info

React native info output:

React Native Environment Info:
    System:
      OS: macOS 10.14.5
      CPU: (4) x64 Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
      Memory: 629.88 MB / 8.00 GB
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 8.11.1 - /usr/local/bin/node
      Yarn: 1.17.3 - ~/.yarn/bin/yarn
      npm: 6.7.0 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 13.0, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
      Android SDK:
        API Levels: 19, 23, 24, 25, 26, 27, 28
        Build Tools: 23.0.1, 23.0.2, 23.0.3, 25.0.0, 25.0.1, 25.0.2, 25.0.3, 26.0.1, 26.0.2, 26.0.3, 27.0.0, 27.0.1, 27.0.2, 27.0.3, 28.0.0, 28.0.0, 28.0.1, 28.0.2, 28.0.3, 29.0.0
        System Images: android-25 | Google Play Intel x86 Atom, android-27 | Google Play Intel x86 Atom, android-28 | Google APIs Intel x86 Atom
    IDEs:
      Android Studio: 3.4 AI-183.6156.11.34.5692245
      Xcode: 11.0/11A420a - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3
      react-native: 0.59.9 => 0.59.9
    npmGlobalPackages:
      create-react-native-app: 1.0.0
      react-native-cli: 2.0.1
      react-native-create-library: 3.1.2
      react-native-git-upgrade: 0.2.7

Library version: 1.1.0

Steps To Reproduce

  1. run code ImagePicker.showImagePicker for pick a video
  2. wait callback response
  3. message: 'Response = ', { error: ‘You don’t have permission.’ }

Describe what you expected to happen:

  1. run code ImagePicker.showImagePicker for pick a video
  2. wait callback response
  3. The video has been uploaded correctly

Reproducible sample code

Use the code in Readme under Usage.

About this issue

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

Commits related to this issue

Most upvoted comments

I fixed it by changing moveItemAtURL to copyItemAtURL at line 459 on ImagePickerManager.m

please, merge it

For those interested in the patch-package file on 0.28.0 (react-native-image-picker+0.28.1.patch) :

diff --git a/node_modules/react-native-image-picker/ios/ImagePickerManager.m b/node_modules/react-native-image-picker/ios/ImagePickerManager.m
index 28d5870..8c060b1 100644
--- a/node_modules/react-native-image-picker/ios/ImagePickerManager.m
+++ b/node_modules/react-native-image-picker/ios/ImagePickerManager.m
@@ -456,7 +456,7 @@ - (void)imagePickerController:(UIImagePickerController *)picker didFinishPicking

                 if (videoURL) { // Protect against reported crash
                   NSError *error = nil;
-                  [fileManager moveItemAtURL:videoURL toURL:videoDestinationURL error:&error];
+                  [fileManager copyItemAtURL:videoURL toURL:videoDestinationURL error:&error];
                   if (error) {
                       self.callback(@[@{@"error": error.localizedFailureReason}]);
                       return;

We encountered an issue on iOS 13 and ended up discovering the same fix that @zirkc recommended. For us, changing copyItemAtURL to moveItemAtURL on that line resolves the issue. The tradeoff is that the original file is not being removed from its source location, which appears to be in a /tmp directory. I assume this /tmp directory will be periodically emptied though.

We are using patch-package to commit this change locally in our own project repo. This could/should probably be a PR here.

Should be fixed with v2.2.1.

Closing for now, if the issue persists, then we can reopen.

Thanks for the contributions and the patience!

Let me check it out.