Flutter not using build number from pubspec.yaml

Viewed 3017

When I run flutter build run I expect the version and build number to user my version in pubspec.yaml 1.1.5+10

However the 10 is always reverting to 1. This is set correctly in info.plist

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

But when I open xcode v12.2 it's changing $(FLUTTER_BUILD_NUMBER) back to

<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>

Somehow xcode itself is reverting these changes in info.plist.enter image description here

[✓] Flutter (Channel stable, 1.22.2, on Mac OS X 10.15.7 19H2, locale en-US)
 
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 12.2)
[!] Android Studio (version 4.1)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
[!] Connected device
    ! No devices available
2 Answers

It's a problem in the ios/Runner.xcodeproj/project.pbxproj file
I solved with this update my version and build number

change this:

CURRENT_PROJECT_VERSION = your buildnumber
MARKETING_VERSION = your version

to:

CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
MARKETING_VERSION = "$(FLUTTER_BUILD_NAME)";

The information in Xcode will not update just because you update and save pubspc.yaml. You must rebuild for iOS in order for the changes to be reflected in Xcode.

Related