react-native-purchases icon indicating copy to clipboard operation
react-native-purchases copied to clipboard

"Native module cannot be null" thrown when importing Purchases in javascript

Open squgeim opened this issue 8 years ago • 6 comments

I have followed the installation instructions and got the project to build successfully. Now, when I import Purchases in my javascript code I get the exception "Native module cannot be null".

screen shot 2018-10-04 at 18 49 30

Where revenueCatService.js:2 is where I have imported Purchases.

Clicking on <unknown> index.js:5:21 takes me to index.js in react-native-purchases:

screen shot 2018-10-04 at 18 50 39

System Xcode 10 MacOS Mojave React native 0.50.4

squgeim avatar Oct 04 '18 13:10 squgeim

I was able to solve the issue by adding libRNPurchases.a in the Linked Frameworks and Libraries.

squgeim avatar Oct 05 '18 07:10 squgeim

@vegaro This is a critical step that is missing from the README. I was getting the same error until I did the step above of adding libRNPurchases.a to Link Binary with Libraries. You might want to add this as one of the gifs.

systemride avatar Feb 27 '19 02:02 systemride

Hey @systemride,

Did you run react-native link react-native-purchases?

That should make sure the RNPurchases lib file is integrated.

jeiting avatar Feb 27 '19 19:02 jeiting

When I run react-native link react-native-purchases all that does is add a line to my Podfile. I am unable to use cocoapods for this so I add it in manually.

systemride avatar Feb 28 '19 17:02 systemride

Got it. Thanks.

We'll run through the integration again cold and make sure we get the missing step added. ᐧ

On Thu, Feb 28, 2019 at 9:04 AM Nick Redmond [email protected] wrote:

When I run react-native link react-native-purchases all that does is add a line to my Podfile. I am unable to use cocoapods for this so I add it in manually.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/RevenueCat/react-native-purchases/issues/23#issuecomment-468353296, or mute the thread https://github.com/notifications/unsubscribe-auth/AAId9iVXuSjKzUQSv1_Gdf41Iesf0FXcks5vSAwygaJpZM4XIEUE .

jeiting avatar Feb 28 '19 17:02 jeiting

I added the step to the README. I was able to reproduce this by running react-native link in a project that contains a Podfile. It looks like react-native link behaves in a different way if it detects the project uses Cocoapods. If the project doesn't use Cocoapods (there is no Podfile) the link to the static library is properly added.

vegaro avatar Mar 01 '19 03:03 vegaro