[package_info_plus] Incorrect prerelease version returned on iOS
This bug occurs only on iOS. Our prerelease versions look like this:
1.0.56-beta.4+1324
On Android, all is well:
// Android
> print((await PackageInfo.fromPlatform()).version)
1.0.56-beta.4
On iOS however, the prerelease bit -beta gets dropped, resulting in a semver-invalid version string.
// iOS
> print((await PackageInfo.fromPlatform()).version)
1.0.56.4
We have some migration logic that runs depending on version which now doesn't run on iOS because it throws.
In case this bit of our pubspec.lock is useful:
package_info_plus:
dependency: "direct main"
description:
name: package_info_plus
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.3"
package_info_plus_macos:
dependency: transitive
description:
name: package_info_plus_macos
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.1"
The version that you want to read from iOS is actuallyCFBundleShortVersionString, and although using a version format as you describe in this issue does indeed works wiht a native swift app (at least on Xcode, have not tested in TestFlight/AppStore) :

It is not the official supported format according to apple. And therefore anything but that format is understandably not accepted by flutter. If you check the build tools, which is the code that parses your version specified at your pubspec.yaml and exports a $FLUTTER_BUILD_NAME to be used by CFBundleShortVersionString
if (targetPlatform == TargetPlatform.ios ||
targetPlatform == TargetPlatform.darwin) {
// See CFBundleShortVersionString at https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
final RegExp disallowed = RegExp(r'[^\d\.]');
It only supports digits and . as specified by apple.
Therefore I think this issue can be closed as there is no way in which we could get the original 1.0.56-beta.4+1324, and if you think this should behave differently you could open a new issue at the main flutter repo.
cc @mhadaily @rubenvereecken
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days
Thanks @fabiancrx I totally missed the reply, I will keep this open until I add this info to the README because we had similar reports before
just change
<key>CFBundleShortVersionString</key>
<string>$(FLUTTER_BUILD_NAME)</string>
to
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
and it will read the correct version