While developing a React-native app I was using process.env to check whether my app was in production or development in my app.config.ts :
import { ExpoConfig, ConfigContext } from 'expo/config';
import Config from "react-native-config"
const isProd = process.env.NODE_ENV === "production"
console.log("CONFIG", Config.NODE_ENV)
export default ({ config }: ConfigContext): ExpoConfig => ({
...config,
extra: {
endpoint: isProd ? "AA" : "BB"
}
...
but i noticed that the process.env its not set when building from Xcode so i tried to add react-native-config in order to use the right .env each time. After installing it with yarn add, adding pod 'react-native-config', :path => '../node_modules/react-native-config' and pod 'react-native-config/Extension', :path => '../node_modules/react-native-config' to podfile and trying to build the app i keep getting the following error:
import { NativeModules } from 'react-native';
^^^^^^
SyntaxError: Cannot use import statement outside a module
@edit I noticed i get the error only when trying to access the Config from app.config.ts during build time, whenever I access it at runtime it works. Now my question is, how should i configure it to make it work also while building, or should i approach it differently?