Solved

Expo Go & RevenueCat: the very basics

  • 23 March 2023
  • 4 replies
  • 1023 views

Badge +5

I’m new to React Native, Expo, and RevenueCat so this is likely very basic but can’t find an answer to this anywhere. I’m following this guide.

I’m not familiar with the lingo yet but I’m pretty sure I’m using the “managed workflow” version of Expo. In terms of development and testing, the only setup I’m currently familiar with is Expo Go -- in other words, running “npm start” on my dev machine, opening Expo Go on my device and connecting, then updating/editing code. This is the only way I know how to write code for my app. Then when I’m ready for full testing on a device, I run an EAS build and download it to my device, but at this point I have absolutely no more visibility into the code, it’s a complete black box -- it’s just a standalone running app on my phone.

My understanding is that the RevenueCat modules do not work with Expo Go. If I try to include them I get a “Invariant Violation: Your JavaScript code tried to access a native module that doesn't exist” error. First question is -- is this expected? I believe so but just want to confirm.

So assuming that’s correct, I assume I would need to disable/remove all such code when developing/testing with Expo Go. So now let’s say I want to actually add in the RevenueCat code and start developing with it. Do I understand correctly that I would have to add the code to my app, run a full development build using eas build --profile development, and download it to my device in order to see the new RevenueCat SDK code running in the app?

I’m not sure how this could possibly work in practice. I would be adding the code completely “blind” without any ability to know whether it even runs without basic errors, then running a build which takes about half an hour, downloading it to my device, and then running it on the device as a standalone app with no development environment around it, no way of viewing logs, debugging, or anything like that. It can’t be that this is how folks are developing with RevenueCat & Expo, so I’m sure I’m missing some very basic development workflow here, but it’s not spelled out anywhere that I can find. Is there some other fundamental way to write and test code that I’m not aware of??

TL;DR How do you actually write new RevenueCat SDK code and test it in an Expo managed workflow app without having to rebuild and run the standalone app every time?

icon

Best answer by asindhu 28 March 2023, 06:41

View original

4 replies

Badge +4

Read this: https://docs.expo.dev/workflow/prebuild/

You need to `prebuild` then you can run `npx expo run:ios` 

Badge +5

@Chani Team thanks for the reply! That is a workflow I didn’t know and it is helpful. It looks like there’s multiple ways to do this and I actually ended up finding the way that makes the the most sense for me -- basically you create a “development” build rather than a “preview” build, and then install that on your device. I think you end up in a similar place as what you described but for me this is closer to the Expo Go workflow I’m used to.

Nowhere in Expo documentation does it explain this, but essentially a development build is sort of like Expo Go except just for your app, and things like RevenueCat that don’t work in Expo Go magically work in your development build.

You run the development build, install it on the device, then run a dev server on your computer, and you can still edit your code in real-time, just like you would in Expo Go. There, I fixed the Expo documentation :)

Anyway given the activity on this thread it seems everyone else somehow magically learns this knowledge on day 1 without it being explicitly written down anywhere, so I won't take the time to explicitly spell it out step by step unless someone specifically asks, in which case of course I’m happy to provide more details.

Badge

Read this: https://docs.expo.dev/workflow/prebuild/

You need to `prebuild` then you can run `npx expo run:ios` 

Yet when you do this on a Windows machine then you get the following error:
“iOS apps can only be built on macOS devices. Use eas build -p ios to build in the cloud.”
 

Badge +4

ok so basically building a dev build you can still run npx expo start to start the dev server and you can debug with the app build running in your physical device? (no expo go). did I get that right>?

Reply