Can't read property showImagePicker of undefined in react native iOS












1















I have tired with this issue




  1. npm install react-native-image-picker@latest --save

  2. react-native link react-native-image-picker


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



const options = {
quality: 1.0,
maxWidth: 500,
maxHeight: 500,
storageOptions: {
skipBackup: true
}
};


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 {
const source = { uri: response.uri };

// You can also display the image using data:
// const source = { uri: 'data:image/jpeg;base64,' + response.data };

this.setState({
avatarSource: source,
});
}
});[enter image description here][1]









share|improve this question





























    1















    I have tired with this issue




    1. npm install react-native-image-picker@latest --save

    2. react-native link react-native-image-picker


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



    const options = {
    quality: 1.0,
    maxWidth: 500,
    maxHeight: 500,
    storageOptions: {
    skipBackup: true
    }
    };


    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 {
    const source = { uri: response.uri };

    // You can also display the image using data:
    // const source = { uri: 'data:image/jpeg;base64,' + response.data };

    this.setState({
    avatarSource: source,
    });
    }
    });[enter image description here][1]









    share|improve this question



























      1












      1








      1








      I have tired with this issue




      1. npm install react-native-image-picker@latest --save

      2. react-native link react-native-image-picker


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



      const options = {
      quality: 1.0,
      maxWidth: 500,
      maxHeight: 500,
      storageOptions: {
      skipBackup: true
      }
      };


      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 {
      const source = { uri: response.uri };

      // You can also display the image using data:
      // const source = { uri: 'data:image/jpeg;base64,' + response.data };

      this.setState({
      avatarSource: source,
      });
      }
      });[enter image description here][1]









      share|improve this question
















      I have tired with this issue




      1. npm install react-native-image-picker@latest --save

      2. react-native link react-native-image-picker


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



      const options = {
      quality: 1.0,
      maxWidth: 500,
      maxHeight: 500,
      storageOptions: {
      skipBackup: true
      }
      };


      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 {
      const source = { uri: response.uri };

      // You can also display the image using data:
      // const source = { uri: 'data:image/jpeg;base64,' + response.data };

      this.setState({
      avatarSource: source,
      });
      }
      });[enter image description here][1]






      ios react-native






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 3 at 13:07









      A.H.Nuri

      817511




      817511










      asked Jan 3 at 12:18









      user30720user30720

      64




      64
























          3 Answers
          3






          active

          oldest

          votes


















          1














          You should restart the packager , every time you run link command in order to take effect. Just cancel the running packager and run react-native run-ios again






          share|improve this answer
























          • uninstall & unlink image-picker. and reinstall and relink this. then after 'react-native run-ios'. so still getting this issue, and also one more time Execute link command and 'react-native run-ios'. but issue is not resolve. and in Android it's working fine.

            – user30720
            Jan 4 at 6:10





















          0














          When you use react-native-link it affects 3 files in your android folder, the build.gradle file (located android/app), the settings.gradle (located android/) and the MainApplication.java file (located android/app/src/java).



          Normally while linking, the dependencies don't get applied in build.gradle at times. Therefore check whether the package (react-native-image-picker) is added, if not go ahead and add it as compile project(':react-native-image-picker').



          Likewise, check all the other files specified above whether the package is defined.



          This is for android (I misunderstood the question as i experienced the same issue and fixed it for android)






          share|improve this answer


























          • in android it's working fine, only getting issue in iOS. thanks.

            – user30720
            Jan 4 at 6:13



















          0














          I also was dealing with this weird issue for a couple of days, in some threats in Github and some other questions here I could not find a solution that really solved the problem from my side till I found this bizarre but effective one!
          Here are the steps I followed:



          1.- Open Xcode and from your project directory, go to the folder libraries. After that, go and find RNImagePicker and open Products folder.



          2.- Go to the Build Phases Tab.



          3.- Then drag and drop libRnImagePicker.a to Link Binary With Libraries.
          This step is the magic one



          This step is the magic one, by doing this a missed link relation in your project is going to be generated by this time your project should look like this:



          4.- Close your project



          5.- Run sudo rm -rf node_modules/.cache



          6.- After this, compile your project either with Xcode or with react-native run-ios
          While the compilation happens and the link dependency gets register it will return an error of cycle dependencies (But this is actually good news, we are almost there!)



          7.- Open again the route described in step 1 and remove libRNImagePicker.a by clicking in the minus buttom.
          enter image description here



          8.- Run your project again, and voila! The react-native-image-picker is working! :)






          share|improve this answer
























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54022160%2fcant-read-property-showimagepicker-of-undefined-in-react-native-ios%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            You should restart the packager , every time you run link command in order to take effect. Just cancel the running packager and run react-native run-ios again






            share|improve this answer
























            • uninstall & unlink image-picker. and reinstall and relink this. then after 'react-native run-ios'. so still getting this issue, and also one more time Execute link command and 'react-native run-ios'. but issue is not resolve. and in Android it's working fine.

              – user30720
              Jan 4 at 6:10


















            1














            You should restart the packager , every time you run link command in order to take effect. Just cancel the running packager and run react-native run-ios again






            share|improve this answer
























            • uninstall & unlink image-picker. and reinstall and relink this. then after 'react-native run-ios'. so still getting this issue, and also one more time Execute link command and 'react-native run-ios'. but issue is not resolve. and in Android it's working fine.

              – user30720
              Jan 4 at 6:10
















            1












            1








            1







            You should restart the packager , every time you run link command in order to take effect. Just cancel the running packager and run react-native run-ios again






            share|improve this answer













            You should restart the packager , every time you run link command in order to take effect. Just cancel the running packager and run react-native run-ios again







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jan 3 at 12:49









            Daniel RaoufDaniel Raouf

            802617




            802617













            • uninstall & unlink image-picker. and reinstall and relink this. then after 'react-native run-ios'. so still getting this issue, and also one more time Execute link command and 'react-native run-ios'. but issue is not resolve. and in Android it's working fine.

              – user30720
              Jan 4 at 6:10





















            • uninstall & unlink image-picker. and reinstall and relink this. then after 'react-native run-ios'. so still getting this issue, and also one more time Execute link command and 'react-native run-ios'. but issue is not resolve. and in Android it's working fine.

              – user30720
              Jan 4 at 6:10



















            uninstall & unlink image-picker. and reinstall and relink this. then after 'react-native run-ios'. so still getting this issue, and also one more time Execute link command and 'react-native run-ios'. but issue is not resolve. and in Android it's working fine.

            – user30720
            Jan 4 at 6:10







            uninstall & unlink image-picker. and reinstall and relink this. then after 'react-native run-ios'. so still getting this issue, and also one more time Execute link command and 'react-native run-ios'. but issue is not resolve. and in Android it's working fine.

            – user30720
            Jan 4 at 6:10















            0














            When you use react-native-link it affects 3 files in your android folder, the build.gradle file (located android/app), the settings.gradle (located android/) and the MainApplication.java file (located android/app/src/java).



            Normally while linking, the dependencies don't get applied in build.gradle at times. Therefore check whether the package (react-native-image-picker) is added, if not go ahead and add it as compile project(':react-native-image-picker').



            Likewise, check all the other files specified above whether the package is defined.



            This is for android (I misunderstood the question as i experienced the same issue and fixed it for android)






            share|improve this answer


























            • in android it's working fine, only getting issue in iOS. thanks.

              – user30720
              Jan 4 at 6:13
















            0














            When you use react-native-link it affects 3 files in your android folder, the build.gradle file (located android/app), the settings.gradle (located android/) and the MainApplication.java file (located android/app/src/java).



            Normally while linking, the dependencies don't get applied in build.gradle at times. Therefore check whether the package (react-native-image-picker) is added, if not go ahead and add it as compile project(':react-native-image-picker').



            Likewise, check all the other files specified above whether the package is defined.



            This is for android (I misunderstood the question as i experienced the same issue and fixed it for android)






            share|improve this answer


























            • in android it's working fine, only getting issue in iOS. thanks.

              – user30720
              Jan 4 at 6:13














            0












            0








            0







            When you use react-native-link it affects 3 files in your android folder, the build.gradle file (located android/app), the settings.gradle (located android/) and the MainApplication.java file (located android/app/src/java).



            Normally while linking, the dependencies don't get applied in build.gradle at times. Therefore check whether the package (react-native-image-picker) is added, if not go ahead and add it as compile project(':react-native-image-picker').



            Likewise, check all the other files specified above whether the package is defined.



            This is for android (I misunderstood the question as i experienced the same issue and fixed it for android)






            share|improve this answer















            When you use react-native-link it affects 3 files in your android folder, the build.gradle file (located android/app), the settings.gradle (located android/) and the MainApplication.java file (located android/app/src/java).



            Normally while linking, the dependencies don't get applied in build.gradle at times. Therefore check whether the package (react-native-image-picker) is added, if not go ahead and add it as compile project(':react-native-image-picker').



            Likewise, check all the other files specified above whether the package is defined.



            This is for android (I misunderstood the question as i experienced the same issue and fixed it for android)







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jan 3 at 13:20

























            answered Jan 3 at 12:31









            RonRon

            4891521




            4891521













            • in android it's working fine, only getting issue in iOS. thanks.

              – user30720
              Jan 4 at 6:13



















            • in android it's working fine, only getting issue in iOS. thanks.

              – user30720
              Jan 4 at 6:13

















            in android it's working fine, only getting issue in iOS. thanks.

            – user30720
            Jan 4 at 6:13





            in android it's working fine, only getting issue in iOS. thanks.

            – user30720
            Jan 4 at 6:13











            0














            I also was dealing with this weird issue for a couple of days, in some threats in Github and some other questions here I could not find a solution that really solved the problem from my side till I found this bizarre but effective one!
            Here are the steps I followed:



            1.- Open Xcode and from your project directory, go to the folder libraries. After that, go and find RNImagePicker and open Products folder.



            2.- Go to the Build Phases Tab.



            3.- Then drag and drop libRnImagePicker.a to Link Binary With Libraries.
            This step is the magic one



            This step is the magic one, by doing this a missed link relation in your project is going to be generated by this time your project should look like this:



            4.- Close your project



            5.- Run sudo rm -rf node_modules/.cache



            6.- After this, compile your project either with Xcode or with react-native run-ios
            While the compilation happens and the link dependency gets register it will return an error of cycle dependencies (But this is actually good news, we are almost there!)



            7.- Open again the route described in step 1 and remove libRNImagePicker.a by clicking in the minus buttom.
            enter image description here



            8.- Run your project again, and voila! The react-native-image-picker is working! :)






            share|improve this answer




























              0














              I also was dealing with this weird issue for a couple of days, in some threats in Github and some other questions here I could not find a solution that really solved the problem from my side till I found this bizarre but effective one!
              Here are the steps I followed:



              1.- Open Xcode and from your project directory, go to the folder libraries. After that, go and find RNImagePicker and open Products folder.



              2.- Go to the Build Phases Tab.



              3.- Then drag and drop libRnImagePicker.a to Link Binary With Libraries.
              This step is the magic one



              This step is the magic one, by doing this a missed link relation in your project is going to be generated by this time your project should look like this:



              4.- Close your project



              5.- Run sudo rm -rf node_modules/.cache



              6.- After this, compile your project either with Xcode or with react-native run-ios
              While the compilation happens and the link dependency gets register it will return an error of cycle dependencies (But this is actually good news, we are almost there!)



              7.- Open again the route described in step 1 and remove libRNImagePicker.a by clicking in the minus buttom.
              enter image description here



              8.- Run your project again, and voila! The react-native-image-picker is working! :)






              share|improve this answer


























                0












                0








                0







                I also was dealing with this weird issue for a couple of days, in some threats in Github and some other questions here I could not find a solution that really solved the problem from my side till I found this bizarre but effective one!
                Here are the steps I followed:



                1.- Open Xcode and from your project directory, go to the folder libraries. After that, go and find RNImagePicker and open Products folder.



                2.- Go to the Build Phases Tab.



                3.- Then drag and drop libRnImagePicker.a to Link Binary With Libraries.
                This step is the magic one



                This step is the magic one, by doing this a missed link relation in your project is going to be generated by this time your project should look like this:



                4.- Close your project



                5.- Run sudo rm -rf node_modules/.cache



                6.- After this, compile your project either with Xcode or with react-native run-ios
                While the compilation happens and the link dependency gets register it will return an error of cycle dependencies (But this is actually good news, we are almost there!)



                7.- Open again the route described in step 1 and remove libRNImagePicker.a by clicking in the minus buttom.
                enter image description here



                8.- Run your project again, and voila! The react-native-image-picker is working! :)






                share|improve this answer













                I also was dealing with this weird issue for a couple of days, in some threats in Github and some other questions here I could not find a solution that really solved the problem from my side till I found this bizarre but effective one!
                Here are the steps I followed:



                1.- Open Xcode and from your project directory, go to the folder libraries. After that, go and find RNImagePicker and open Products folder.



                2.- Go to the Build Phases Tab.



                3.- Then drag and drop libRnImagePicker.a to Link Binary With Libraries.
                This step is the magic one



                This step is the magic one, by doing this a missed link relation in your project is going to be generated by this time your project should look like this:



                4.- Close your project



                5.- Run sudo rm -rf node_modules/.cache



                6.- After this, compile your project either with Xcode or with react-native run-ios
                While the compilation happens and the link dependency gets register it will return an error of cycle dependencies (But this is actually good news, we are almost there!)



                7.- Open again the route described in step 1 and remove libRNImagePicker.a by clicking in the minus buttom.
                enter image description here



                8.- Run your project again, and voila! The react-native-image-picker is working! :)







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Feb 4 at 6:10









                Mauricio SartoriMauricio Sartori

                1,19731624




                1,19731624






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54022160%2fcant-read-property-showimagepicker-of-undefined-in-react-native-ios%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Angular Downloading a file using contenturl with Basic Authentication

                    Olmecas