4

I'm trying to manage my React Native app project (CRNA ejected) using different package names so I can release/test different flavors:

com.mydomain.internal
com.mydomain.alpha
com.mydomain.beta

Ideally, I want to develop & test com.mydomain.internal app package on my git master branch, and push the change to alpha branch (this branch should build com.mydomain.alpha package), and then push the change to beta branch where it should build com.mydomain.beta app package.

I want to avoid manually change the package names for every release because it touches a lot of files and could easily break things. I'm wondering if there's a good way to help me maintain/update multiple app flavors/versions like above. If icons can be changed too, please also point that out, so that I can create different icons for different flavors.

(I was thinking about config the manifests and read the package name from a static file, but doesn't seem to work)

Thanks!

Allan Jiang
  • 11,063
  • 27
  • 104
  • 165

2 Answers2

0

Consider that a script can determine the name of the checked out branch with:

branch=$(git rev-parse --symbolic --abbrev-ref HEAD)

That means you could (using "config" here as a generic term, replace it by the right file to modify):

  • version only a template file config.tpl
  • version value files named after the branches: config.dev, config.master: since they are different, there is no merge issue when merging or switching branches.

Finally, you would register (in a .gitattributes declaration) a content filter driver.

smudge (image from "Customizing Git - Git Attributes", from "Pro Git book")

The smudge script, associated to the template file (config.tpl), would generate (automatically on git checkout) the actual config file by looking values in the right config.<branch> value file.
The generated actual config file remains ignored (by the .gitignore).

See a complete example at "git smudge/clean filter between branches".

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

I have found a good solution to this problem called Build Varient for Android. This article has well explained how to set it up: https://medium.com/@ywongcode/building-multiple-versions-of-a-react-native-app-4361252ddde5

Allan Jiang
  • 11,063
  • 27
  • 104
  • 165