cordova-plugin-app-version
cordova-plugin-app-version copied to clipboard
AppVersion.build on iOS needs to be a string
I've been playing around with cordova-plugin-app-version for a bit, and noticed some strange behavior on iOS.
iOS uses two string values to indicate the version:
- CFBundleShortVersionString, which represents the release version # of the app (e.g., "1.0.0"). This shows up as the "Version" value in Xcode: https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/20001431-111349
- CFBundleVersion, which represents the build version number of the bundle (e.g., "1.0.0b3" for beta 3 of the 1.0.0 release). This shows up as the "Build" value in Xcode: https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/20001431-102364
It looks like the file app-version.js is trying to parse the latter value as an integer value:
_this.build = parseInt(info.build, 10);
Which is causing some weird return values.
Not sure what the proper fix is here, since Android's VersionCode is an integer. Maybe splitting this API into two, an integer for Android and a string for iOS?
Just added a line locally to app_version.js, just after the _this.build... line:
_this.buildString = info.build;
This adds a new API to pass back the CFBundleVersion without converting it, which seems to address values like 1.0.0b3 in that field. I tested it on both Android and iOS without issue.
Should I create a PR to fold this change in?