Flutter not using build number from pubspec.yaml
Asked Answered
M

5

17

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
Mumps answered 13/12, 2020 at 15:48 Comment(0)
E
26

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)";

Electrophorus answered 15/4, 2021 at 12:31 Comment(1)
worth noting that CURRENT_PROJECT_VERSION and MARKETING_VERSION exist 3 times in the file, not just onceHeiser
T
5

I have encountered similar problem multiple times. What I did was set Generated configuration for all profiles [PROFILE] (Debug, Release, Profile).

Go to XCode -> Runner -> Project (Runner) -> Info.

On Target level all Runners were using Pods-Runner.[PROFILE]. On Project level there was no configuration used, so I selected Generated for all.

enter image description here

I don't know what are the actual implications of this change, but build version and name are picked up from Generated.xcconfig file now.

Thermosetting answered 23/2, 2023 at 15:53 Comment(0)
S
4

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.

Slaphappy answered 14/12, 2020 at 5:46 Comment(2)
Rebuild means running “flutter build iOS” ? Need more detailed steps.Boyfriend
this should be the right answer. Yes its "flutter build ios"Canty
C
3

This is because Flutter build/run CLI overwrites iOS/Android build version from pubspec.yaml.

In my case, I use manually build(gym command of fastlane) and build version was same as before.

Use flutter build for build or you have to manually overwrite the version.

Caucasian answered 27/9, 2022 at 1:14 Comment(1)
Running flutter build ios is required. Otherwise you have to: 1. Manually edit Info-Debug.plist and Info-Release.plist and update those keys/rows (FLUTTER_BUILD_NAME & FLUTTER_BUILD_NUMBER respectively). 2. Then manually change version and build number from your Target -> General tab -> Identity section -> "Version" and "Build"Sharpnosed
S
0

My solution was to go to the file located at this address:

./ios/runner.xcodeproj/project.pbxproj

Once opened the file had the following value defined:

FLUTTER_BUILD_NUMBER = 5

I replaced it with this:

FLUTTER_BUILD_NUMBER = "$(FLUTTER_BUILD_NUMBER)";

I got the version number working in the app using flavors.

Subterranean answered 26/10, 2023 at 7:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.