Tomas Baran
Tomas Baran

Reputation: 1983

How to force Flutter to update my version and build number?

  1. I've changed my version in pubspec.yaml to 1.0.1+1 (from 1.0.0+3)
  2. flutter clean
  3. flutter build ios
  4. When I open [project]/ios/Runner.xcworkspace it still shows me 1.0.0 version.

What am I doing wrong? How can I force Xcode to update my version from CLI or pubspec.yaml?

This is how my Info.plist looks like:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>$(DEVELOPMENT_LANGUAGE)</string>
    <key>CFBundleDisplayName</key>
    <string>Name</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>Sundee</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>$(MARKETING_VERSION)</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>$(CURRENT_PROJECT_VERSION)</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
    <string>Your location will be used to determine sun angle.</string>
    <key>NSLocationAlwaysUsageDescription</key>
    <string>Your location will be used to determine sun angle.</string>
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>Your location will be used to determine sun angle.</string>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIMainStoryboardFile</key>
    <string>Main</string>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UIViewControllerBasedStatusBarAppearance</key>
    <false/>
</dict>
</plist>

Upvotes: 26

Views: 15506

Answers (7)

This is how you fix it.

The issue was likely due to the fact that your Info.plist was not configured to automatically pick up the version and build number from your pubspec.yaml. The following keys in Info.plist were not set to use the Flutter build variables.

xml

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

To fix this, just update these key's values to:

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

This way, the version and build number from pubspec.yaml are automatically used in the iOS build. Without this, Xcode was not updating the version and build number even after you changed them in pubspec.yaml and ran flutter build ios.

Happy Coding 🥳

Upvotes: 0

hugo
hugo

Reputation: 1245

@louise's answer got me pretty close but, weirdly, mine was the exact opposite. My Configurations look like this:

enter image description here

Upvotes: 1

Louise
Louise

Reputation: 41

In my case, I had different flavors for my app, which I kind of understand to be schemes in XCode.

After doing flutter clean, since my app was done almost a year ago, I also decided to remove the android and ios folders to start from scratch, even the custom configurations. After that, I did pod install by setting my configurations to None first.

And then I encountered the issue. I did all the above solutions but didn't really work.

Turns out doing pod install set the Runner targets' build configs to Pods-Runner.<flavor>. I was able to have it update again after setting it to the Generated.xcconfig file.

before

after

I decided to set the Project config to the generated Pods-Runner.<flavor>, though I'm still not quite sure why, just felt like it was generated for a reason. Anyone who could help would be greatly appreciated.

Upvotes: 1

Kalyan Chandra
Kalyan Chandra

Reputation: 169

To achieve this, you have to add some values in CfBundleVersionShortString

Like:

   <key>CFBundleShortVersionString</key>
   <string>1.0</string> 

And give the build value in Runner as 1.0 and version as 1.0

screenshot

Upvotes: 0

Tomas Baran
Tomas Baran

Reputation: 1983

I got it. It's because my lines in my Info.plist did not look like the following:

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

Anyone has an idea why I had $(MARKETING_VERSION) and $(CURRENT_PROJECT_VERSION)?

Upvotes: 36

Elvis Teles
Elvis Teles

Reputation: 898

The same thing happened to me.

I think that when I used the xcode interface he changed the file ios/Runner.xcodeproj/project.pbxproj and he didn't get the value automatically

I solved it like this.

change this:

CURRENT_PROJECT_VERSION = your buildnumber
MARKETING_VERSION = your version

to:

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

this appears 3 times

Upvotes: 49

Yousif khalid
Yousif khalid

Reputation: 6465

You need also get package.

CFBundleShortVersionString is the public "name" of the version (example: "2.5", or "3.8.1"). You must increase it at each release.

CFBundleVersion is the private build number. It is not seen on the AppStore. You must increase it at each upload. It means that if you ever reject a binary before it goes online, and you want to upload a new binary, it will have the same

CFBundleShortVersionString but must have a higher CFBundleVersion (example: public "2.5", private "2.5", and then binary reject, and re-upload private "2.5.1")

Upvotes: -1

Related Questions