plus_plugins icon indicating copy to clipboard operation
plus_plugins copied to clipboard

[package_info_plus] Empty String for version and buildNumber

Open leo-mangold opened this issue 2 years ago • 6 comments

System info

Issue occurs on: iOS (not yet tested on android) Plugin name: package_info_plus Plugin version: 1.3.0 Flutter doctor output:

[✓] Flutter (Channel stable, 2.8.1, on macOS 12.0.1 21A559 darwin-arm, locale
    en-DE)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] VS Code (version 1.63.2)
[✓] Connected device (2 available)

• No issues found!

My Problem

This code returns no version nor buildNumber.

import 'package:package_info_plus/package_info_plus.dart';

class AppInfo {
  static Future<String> get appVersion async {
    // PackageInfoPlus not working...
    // version & buildNumber returns empty string

    PackageInfo packageInfo = await PackageInfo.fromPlatform();

    String appName = packageInfo.appName;
    String packageName = packageInfo.packageName;
    String version = packageInfo.version;
    String buildNumber = packageInfo.buildNumber;

    print(appName);
    print(packageName);
    print(version);
    print(buildNumber);

    return '$version+$buildNumber';
  }
}

Output:

flutter: Groceries
flutter: <My Package Id (hidden here)>
flutter:
flutter:

So the appName and packageName work but the versions do not.

Yes I have cleaned the build folder multiple times.

Help is much appreciated :)

leo-mangold avatar Jan 02 '22 12:01 leo-mangold

Are you still experiencing this in the latest versions of the plugin?

fabiancrx avatar Apr 22 '22 18:04 fabiancrx

I don’t know. I created an entire new flutter project and copied the source code over. Now everything works fine

leo-mangold avatar Apr 23 '22 08:04 leo-mangold

I have the same issue on iOS 15.4.1

LostInDarkMath avatar Apr 25 '22 15:04 LostInDarkMath

More details:

  • Flutter version: 2.10.4
  • Package Info Plus version: 1.4.2
  • iOS version: 15.4.1

Logs

    PackageInfo packageInfo = await PackageInfo.fromPlatform();

    debugPrint(
        'appName: ${packageInfo.appName}, '
        'packageName: ${packageInfo.packageName}, '
        'version: ${packageInfo.version}, '
        'buildNumber: ${packageInfo.buildNumber}, '
        'buildSignature: ${packageInfo.buildSignature}'
    );

gives:

appName: foo, packageName: com.foo.bar, version: , buildNumber: , buildSignature:

LostInDarkMath avatar Apr 25 '22 17:04 LostInDarkMath

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 25 '22 00:06 github-actions[bot]

removing stale label

LostInDarkMath avatar Jun 26 '22 17:06 LostInDarkMath

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 25 '22 00:09 github-actions[bot]

removing stale label again

LostInDarkMath avatar Sep 25 '22 06:09 LostInDarkMath

This issue doesn't seem to be reproducible with the example project in package_info_plus.

The app version is read from the CFBundleShortVersionString and CFBundleVersion.

Can you make sure that those values exist on your info.plist?

e.g.

	<key>CFBundleShortVersionString</key>
	<string>$(FLUTTER_BUILD_NAME)</string>
	<key>CFBundleVersion</key>
	<string>$(FLUTTER_BUILD_NUMBER)</string>

miquelbeltran avatar Sep 25 '22 12:09 miquelbeltran

@miquelbeltran Yes, I have these values in my info.plist file. And there wasn't a time where those values don't exist.

LostInDarkMath avatar Sep 25 '22 12:09 LostInDarkMath

Inside your iOS project, there should be a Generated.xcconfig file that should contain something like this:

FLUTTER_BUILD_NAME=1.2.3
FLUTTER_BUILD_NUMBER=4

If you use a custom xcconfig, you need to make sure you are including the generated one as well.

Also, can you confirm it works for you when running the example inside the package_info_plus folder?

miquelbeltran avatar Sep 25 '22 13:09 miquelbeltran

Yes, also the values in the Generated.xcconfig are correct.

Infortunately, I haven't a Mac currently. @wieland-s Could you try this out please?

LostInDarkMath avatar Sep 25 '22 13:09 LostInDarkMath

The thing is that the plugin code is like two lines, so not a lot can go wrong there, :)

The plugin is returning two null values, and for some reason it is not reading correctly the version from the info.plist. Or the version in the info.plist is missing.

If I do the following:

  1. create new flutter project with flutter create package_example
  2. add plugin with flutter pub add package_info_plus
  3. replace the void _incrementCounter() async { code and add the logline you provided
  4. Run the app, tap the Floating Action Button, the print output is correct:
flutter: appName: Package Example, packageName: com.example.packageExample, version: 1.0.0, buildNumber: 1, buildSignature:

Please provide a step by step way to reproduce the issue, otherwise we can't help.

miquelbeltran avatar Sep 25 '22 13:09 miquelbeltran

@miquelbeltran Can this be related to https://github.com/flutter/flutter/issues/20761#issuecomment-493434578?

Anyways, I'll try to reproduce this the next days.

LostInDarkMath avatar Sep 25 '22 15:09 LostInDarkMath

Would make a lot of sense! Perhaps a clean/build or even regenerating the ios folder is a solution to this problem.

miquelbeltran avatar Sep 25 '22 16:09 miquelbeltran

Okay, I cannot reproduce the issue here with the example app of your main branch.

LostInDarkMath avatar Oct 13 '22 14:10 LostInDarkMath

Seems like the issue isn't reproducible anymore

vbuberen avatar Dec 10 '22 20:12 vbuberen