Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16750

How do I make my React Native module automatically add an entry to a project's Podfile after running react-native link?

$
0
0

I want to create a React Native module that can be installed using

npm install --save react-native-my-module
react-native link
cd ios && pod install

Using React Native 0.61.2 and a few required SDKs


  1. Followed the instructions here to create a basic React Native module.

  2. Installed the module using npm install --s 'path to my-module'

  3. Ran react-native link
  4. Installed the pod with cd ios && pod install

I saw my pod being successfully installed.


The default native module skeleton sets up a method called sampleMethod that I invoke using

var myModule = NativeModules.MyModule;
console.log(myModule.sampleMethod());

But I get the following error message

TypeError: Cannot read property 'sampleMethod' of undefined

To fix the error I have to manually link the module with react-native link my-module but then React Native complains

error React Native CLI uses autolinking for native dependencies, but the following modules are linked manually:

- react-native-my-module (to unlink run: "react-native unlink react-native-my-module")

What am I missing here? Do I have to manually link the module or is there a configuration file I can edit somewhere to avoid that?


Viewing all articles
Browse latest Browse all 16750

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>