14

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
user1961
  • 1,270
  • 2
  • 17
  • 27

4 Answers4

21

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

Elvis Teles
  • 738
  • 6
  • 9
  • 4
    worth noting that `CURRENT_PROJECT_VERSION` and `MARKETING_VERSION` exist 3 times in the file, not just once – Lynob Oct 12 '22 at 19:13
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.

Lee3
  • 2,882
  • 1
  • 11
  • 19
4

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.

Tomas Zubrik
  • 347
  • 3
  • 11
2

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.

MJ Studio
  • 3,947
  • 1
  • 26
  • 37
  • 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" – om-ha Jan 01 '23 at 16:46