React-native-image-crop-picker: Undefined is not an object when calling openPicker

Created on 28 Sep 2016  路  8Comments  路  Source: ivpusic/react-native-image-crop-picker

Having an issue when trying to open the image picker or the camera.

I'm calling the picker like this:

import ImagePicker from 'react-native-image-crop-picker'

[...]

ImagePicker.openPicker({
    multiple: true,
  }).then((images) => {
    console.log(images)
  })

Which is essentially copy pasted from the readme.
Tried to rm -rf the node_modules folder, pod install, clean project, build, cleared watchman watches... Without any result...

Is this a bug in the library, or did I miss something?

Version

  • react-native-image-crop-picker v0.9.6 (have the issue on 0.9.5 as well)
  • react-native v0.34.1 (have the issue on 0.33.0 as well)

    Platform

  • iOS (9.3)

    Attachments

capture d ecran 2016-09-28 a 18 36 43

Most helpful comment

As we investigated more by email, I've finally been able to sort it out.
Posting this here, in case someone encounters a similar issue.

Every step might not be useful, however I'm not sure exactly which step fixed it for my specific case:

Here鈥檚 what I did:

  • If you have one, delete npm-shrinkwrap.json
  • Update react, react-native to their latest available version (15.3.2 and 0.34.1 respectively in my case)
  • If you use it, npm shrinkwrap
  • rm -rf node_modules Pods
  • rm Podfile.lock
  • Clean project in Xcode (CMD+Shift+K)
  • npm install
  • pod install
  • rnpm unlink react-native-image-crop-picker
  • rnpm link react-native-image-crop-picker
  • Build

All 8 comments

probably you didn't link picker with your project. Try react-native link react-native-image-crop-picker

That's the thing, I already did it twice with no luck. The output of the CLI now says that it has already been linked, and yet it's still not working

I cannot reproduce it :/. This is most likely some installation issue. Check in xcode if library is added to Link Binary With Libraries section.

Ok, somehow I had to rnpm unlink and react-native link again. Probably the first linking dit not work out properly and new attempts only stated already linked without verifying if it was properly linked or not.

But now I have another issue.
Whenever I call ImagePicker.openPicker, I have a native exception:

2016-09-29 10:32:56.985 MyApp[10306:306515] -[QBImagePickerController setMediaType:]: unrecognized selector sent to instance 0x7fb898dbc4c0
2016-09-29 10:32:56.988 MyApp[10306:306515] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[QBImagePickerController setMediaType:]: unrecognized selector sent to instance 0x7fb898dbc4c0'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000113c14d85 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000011315bdeb objc_exception_throw + 48
    2   CoreFoundation                      0x0000000113c1dd3d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x0000000113b63cfa ___forwarding___ + 970
    4   CoreFoundation                      0x0000000113b638a8 _CF_forwarding_prep_0 + 120
    5   MyApp                               0x000000010d8d91c5 __48-[ImageCropPicker openPicker:resolver:rejecter:]_block_invoke_2 + 2069
    6   libdispatch.dylib                   0x0000000114551d9d _dispatch_call_block_and_release + 12
    7   libdispatch.dylib                   0x00000001145723eb _dispatch_client_callout + 8
    8   libdispatch.dylib                   0x000000011455a1ef _dispatch_main_queue_callback_4CF + 1738
    9   CoreFoundation                      0x0000000113b6e0f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    10  CoreFoundation                      0x0000000113b2fb99 __CFRunLoopRun + 2073
    11  CoreFoundation                      0x0000000113b2f0f8 CFRunLoopRunSpecific + 488
    12  GraphicsServices                    0x000000011521ead2 GSEventRunModal + 161
    13  UIKit                               0x00000001113d6f09 UIApplicationMain + 171
    14  MyApp                               0x000000010d2737df main + 111
    15  libdyld.dylib                       0x00000001145a692d start + 1
    16  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

Some updates

When running on an actual device (versus the simulator), I'm having more information about the crash:

capture d ecran 2016-09-29 a 11 07 04

And here's the much shorter stacktrace, still unrecognized selector sent to instance though:

2016-09-29 11:05:04.084362 AllSquare[359:30497] -[QBImagePickerController setMediaType:]: unrecognized selector sent to instance 0x1094b81c0
2016-09-29 11:05:04.086736 AllSquare[359:30497] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[QBImagePickerController setMediaType:]: unrecognized selector sent to instance 0x1094b81c0'
*** First throw call stack:
(0x189a841c0 0x1884bc55c 0x189a8b278 0x189a88278 0x18998259c 0x100644234 0x10136d25c 0x10136d21c 0x101372284 0x189a31f2c 0x189a2fb18 0x18995e048 0x18b3e1198 0x18f937818 0x18f932550 0x100012d68 0x1889405b8)
libc++abi.dylib: terminating with uncaught exception of type NSException

before pod install you have to put "platform :ios, '8.0'" so cocoapods will download latest version of qbimagepicker. Probably remove pods directory and install it again with mentioned setting.

platform :ios, '8.0' has always been in my Podfile :/

As we investigated more by email, I've finally been able to sort it out.
Posting this here, in case someone encounters a similar issue.

Every step might not be useful, however I'm not sure exactly which step fixed it for my specific case:

Here鈥檚 what I did:

  • If you have one, delete npm-shrinkwrap.json
  • Update react, react-native to their latest available version (15.3.2 and 0.34.1 respectively in my case)
  • If you use it, npm shrinkwrap
  • rm -rf node_modules Pods
  • rm Podfile.lock
  • Clean project in Xcode (CMD+Shift+K)
  • npm install
  • pod install
  • rnpm unlink react-native-image-crop-picker
  • rnpm link react-native-image-crop-picker
  • Build
Was this page helpful?
0 / 5 - 0 ratings

Related issues

DISKONEKTeD picture DISKONEKTeD  路  3Comments

Martian2Lee picture Martian2Lee  路  3Comments

fmcruz picture fmcruz  路  3Comments

equesteo picture equesteo  路  3Comments

tximpa91 picture tximpa91  路  3Comments