Is there a way to use packages incompatible with Expo Go only when a specific environment variable is set?
I am trying to use react-native-google-mobile-ads however, I work on a Windows PC and cannot build using expo prebuild unless I switch to my Mac. I am wondering if I can use an environment variable to only use said package when wanted. I tried doing this:
// App.tsx
// inside App() and useEffect()
if (process.env.EXPO_PUBLIC_BRANCH == "PRODUCTION") {
mobileAds()
.initialize()
.finally(() => {
setAdsLoaded(true);
});
} else {
setAdsLoaded(true);
}
However it still seems to throw the error Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RNGoogleMobileAdsModule' could not be found. Verify that a module by this name is registered in the native binary., js engine: hermes I sort of expected this as it's still including the package and (I guess) typescript still compiles this code so needs the package either way.