plus_plugins icon indicating copy to clipboard operation
plus_plugins copied to clipboard

[package_info_plus] Incorrect prerelease version returned on iOS

Open rubenvereecken opened this issue 4 years ago • 3 comments

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"

rubenvereecken avatar Jul 31 '21 10:07 rubenvereecken

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) : image

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

fabiancrx avatar Apr 22 '22 18:04 fabiancrx

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

github-actions[bot] avatar Jun 22 '22 00:06 github-actions[bot]

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

github-actions[bot] avatar Sep 21 '22 00:09 github-actions[bot]

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

miquelbeltran avatar Sep 28 '22 15:09 miquelbeltran

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

ahmedashraf344 avatar Mar 27 '24 13:03 ahmedashraf344