问题
I followed the Readme from react-native-image-picker with both manual and automatic linking (tried both separately).
When I launch simulator from terminal using react-native run-ios
I get the error. When launching from Xcode it works fine, I can access the CameraRoll picker no problem.
Here are the versions I'm using:
"react-native": "0.43.3",
"react-native-image-picker": "^0.26.3",
I saw a similar thread here stackoverflow and it seems I'm not the only one having this issue.
Thank you for helping.
The full error:
undefined is not an object (evaluating 'ImagePickerManager.showImagePicker')
showImagePicker
index.js:28:30
selectPhotoTapped
CamPick.js:31:32
touchableHandlePress
TouchableOpacity.js:126:45
_performSideEffectsForTransition
Touchable.js:746:34
_receiveSignal
Touchable.js:664:44
touchableHandleResponderRelease
Touchable.js:433:24
invokeGuardedCallback
ReactErrorUtils.js:30:9
executeDispatch
EventPluginUtils.js:99:42
executeDispatchesInOrder
EventPluginUtils.js:127:20
executeDispatchesAndRelease
EventPluginHub.js:37:46
forEachAccumulated
forEachAccumulated.js:30:16
processEventQueue
EventPluginHub.js:227:8
runEventQueueInBatch
ReactEventEmitterMixin.js:18:35
handleTopLevel
ReactEventEmitterMixin.js:38:25
<unknown>
ReactNativeEventEmitter.js:113:8
perform
Transaction.js:149:24
batchedUpdatesWithControlledComponents
ReactGenericBatching.js:51:26
_receiveRootNodeIDEvent
ReactNativeEventEmitter.js:111:40
receiveTouches
ReactNativeEventEmitter.js:200:8
__callFunction
MessageQueue.js:244:47
<unknown>
MessageQueue.js:108:26
guard
MessageQueue.js:46:4
callFunctionReturnFlushedQueue
MessageQueue.js:107:10
回答1:
It seemed that Xcode was not linking the files properly, the trick who worked for me was to:
- Open Xcode project 'MainProject.xcodeproj'
- Under MainProject under Libraries I would go find RNImagePicker.xcodeproj
- Under RNImagePicker.xcodeproj I would right click and delete both files ImagePickerManager.h and ImagePickerManager.m
- Right click on RNImagePicker.xocdeproj to 'Add files to ...' and then would select both files from 'node_modules/react-native-maps/ios/ImagePickerManager.h and ImagePickerManganer.m'
Hope it helps somebody who might have the same problem ;)
来源:https://stackoverflow.com/questions/43983519/react-native-image-picker-undefined-is-not-an-object-evaluating-imagepickerm