I've followed all of the iOS installation instructions for the package react-native-image-picker
, but it still errors any time I try to use the showImagePicker()
method.
It tells me it cannot read property "showImagePicker" of undefined
.
I have the package imported at the top of my file var ImagePicker = require('react-native-image-picker');
, I have done react-native link
multiple times, I have added RNImagePicker.xcodeproj
to my libraries folder, I have added RNImagePicker.a
to "Link Binary with Libraries", I have added the permissions to my info.plist
file.
I have done everything in the documentation, but still nothing works.
Here is my JS:
import React from 'react';
import PropTypes from 'prop-types';
import { StyleSheet, Text, View, Image, ScrollView, TextInput, TouchableOpacity, KeyboardAvoidingView } from 'react-native';
var ImagePicker = require('react-native-image-picker');
export default class ProfilePicUploaderPage extends React.Component {
state = {
ProfilePicLocalSource: null,
ProfilePicRemoteSource: null
}
ChoosePhoto(){
console.log(SOCButton);
var options = {
title: 'Select Avatar',
customButtons: [
{name: 'fb', title: 'Choose Photo from Facebook'},
],
storageOptions: {
skipBackup: true,
path: 'images'
}
};
ImagePicker.showImagePicker(options, (response) => {
console.log('Response = ', response);
if (response.didCancel) {
console.log('User cancelled image picker');
}
else if (response.error) {
console.log('ImagePicker Error: ', response.error);
}
else if (response.customButton) {
console.log('User tapped custom button: ', response.customButton);
}
else {
let source = { uri: response.uri };
this.setState({
avatarSource: source
});
}
});
}
render(){
return(<all of my JSX>);
}
The only lead I have as to what's happening is that when I try to build my app in Xcode, it fails with the error clang: error: linker command failed with exit code 1 (use -v to see invocation)
.
Does anyone have an idea of what's going on?