Baterka
Baterka

Reputation: 3684

How to have React Native project versions seamless across project and platforms

It is very annoying to change build version of my React Native (not Expo) application every time I build it.

It needs to be changed in at leats 4 places at moment:

Is there any way to automatize this? For example every place gets updates when package.json version changes?

Upvotes: 1

Views: 179

Answers (1)

Vitaly Tr
Vitaly Tr

Reputation: 81

For android you could have in /android/build.gradle a function:

import groovy.json.JsonSlurper

def getNPMVersion() {
    def file = new File("$rootDir/../package.json")
    def packageJson = new JsonSlurper().parseText(file.text)
    return packageJson["version"]
}

and then in your /android/app/build.gradle you'd use versionName getNPMVersion()

For ios I'm pretty sure you'll need a script that overrides the Info.plist

Upvotes: 2

Related Questions