I'm building a react native iOS app, and would like to:
1) Display the app's current version from the package.json file in the app itself.
Specifically: Now that I've implemented codepush, I want to display the current app version on the Settings page, so that app users can tell if their app has been upgraded. I currently set the version number in the package.json file and use this shell script to propagate that to the xcode project. If there's a better way to manage/update a projects version number, please let me know!
2) Execute certain .js code based on build variables from xcode.
I have three build configurations (Debug, Staging, Release) setup in xcode, and I would like to specify the updateDialog: true
flag to codepush only for Staging builds. I would also like to display on the settings page whether this is a Debug, Staging or Release build.
What is the best way to accomplish these things?
Are there best practices for setting/syncing a project's version number and accessing it within the app, or is this stuff usually just coded by hand?
Fwiw, this answer is relevant, but doesn't say what specific environment variables xcode defines that would help me here, and doesn't speak to the versioning question.