7

I need to make a react native app which will be used to produce other apps using the same code (changing some logos, colors, a few features depending on the case etc)

On Android with Java I was using flavors, but with Expo to generate builds variant on Android & iOS and not having to duplicate code/projects, i'm not sure how I can do this properly. Any best practice?

Gabriel Morin
  • 2,100
  • 1
  • 14
  • 26
  • 1
    also need an answer for this.. – EnriqueDev Aug 09 '17 at 15:12
  • I'd recommend creating separate app.json files and switching between them with https://github.com/oliverbenns/expo-deploy. If you want to customize more code, then perhaps the easiest solution is to have a shared npm package that all your apps use. – ide Aug 09 '17 at 20:14
  • refer link- https://stackoverflow.com/a/58271608/5515225. or https://stackoverflow.com/a/66673498/5515225 – Rakesh Medpalli Mar 17 '21 at 13:00

1 Answers1

0

Expo now supports variants, but only if you use Expo Application Services (EAS).

There is a bit too much code to include it all, but the key bit is doing this is app.config.js:

const IS_DEV = process.env.APP_VARIANT === "development";

export default {
  // You can also switch out the app icon and other properties to further
  // differentiate the app on your device.
  name: IS_DEV ? "MyApp (Dev)" : "MyApp",
  slug: "my-app",
  ios: {
    bundleIdentifier: IS_DEV ? "com.myapp.dev" : "com.myapp",
  },
  android: {
    package: IS_DEV ? "com.myapp.dev" : "com.myapp",
  },
};

For more info: https://docs.expo.dev/build-reference/variants/

dain
  • 6,475
  • 1
  • 38
  • 47
  • Yea, I read this but I do not understand whether they want us to create a new file called app.config.js or what exactly? Because app.config.js is not part of the files created when I initiated my app. I wish there is a video that explains this better. – AnatuGreen Apr 19 '23 at 17:18
  • @AnatuGreen `app.config.js` is the same as `app.json` (and replaces it), but you can add scripting as it's Javascript. There's a bit on that page saying "Let's convert this to app.config.js so we can make it more dynamic". – dain Apr 20 '23 at 18:20