plus_plugins
plus_plugins copied to clipboard
[package_info_plus] Empty String for version and buildNumber
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 :)
Are you still experiencing this in the latest versions of the plugin?
I don’t know. I created an entire new flutter project and copied the source code over. Now everything works fine
I have the same issue on iOS 15.4.1
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:
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
removing stale label
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
removing stale label again
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 Yes, I have these values in my info.plist
file. And there wasn't a time where those values don't exist.
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?
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?
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:
- create new flutter project with
flutter create package_example
- add plugin with
flutter pub add package_info_plus
- replace the
void _incrementCounter() async {
code and add the logline you provided - 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 Can this be related to https://github.com/flutter/flutter/issues/20761#issuecomment-493434578?
Anyways, I'll try to reproduce this the next days.
Would make a lot of sense! Perhaps a clean/build or even regenerating the ios folder is a solution to this problem.
Okay, I cannot reproduce the issue here with the example app of your main
branch.
Seems like the issue isn't reproducible anymore