如何强制 Flutter 更新我的版本和内部版本号?

Tom*_*ran 5 deployment xcode command-line-interface flutter

  1. 我已将 pubspec.yaml 中的版本更改为 1.0.1+1(从 1.0.0+3)
  2. flutter clean
  3. flutter build ios
  4. 当我打开 [project]/ios/Runner.xcworkspace 时,它​​仍然显示 1.0.0 版本。

我究竟做错了什么?如何强制 Xcode 从 CLI 或 pubspec.yaml 更新我的版本?

这是我的 Info.plist 的样子:

<?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>
Run Code Online (Sandbox Code Playgroud)

Tom*_*ran 12

我知道了。这是因为我在 Info.plist 中的行看起来不像这样:

<key>CFBundleShortVersionString</key> <string>$(FLUTTER_BUILD_NAME)</string> <key>CFBundleVersion</key> <string>$(FLUTTER_BUILD_NUMBER)</string>
Run Code Online (Sandbox Code Playgroud)

任何人都知道为什么我有$(MARKETING_VERSION)$(CURRENT_PROJECT_VERSION)

  • 当您在 Targets -&gt; General -&gt; Identity 下更改“Version”和“Build”时,XCode 会添加 $(MARKETING_VERSION) 和 $(CURRENT_PROJECT_VERSION) (2认同)

Elv*_*les 5

这样的事情我也经历过。

我认为当我使用xcode接口时他更改了文件ios/Runner.xcodeproj/project.pbxproj并且他没有自动获取值

我是这样解决的。

改变这个:

CURRENT_PROJECT_VERSION = your buildnumber
MARKETING_VERSION = your version

到:

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

这出现了 3 次

  • 在尝试了所有不同的事情(包括 plist 更改)之后,这对我来说成功了。谢谢! (4认同)
  • 这是正确答案,应标记为正确答案。当您手动更改 Xcode 内的内部版本号时会出现此问题。此解决方案将纠正问题 (3认同)