Flutter:应用程序的 Info.plist 不包含有效的 CFBundleVersion

Sam*_*uel 2 xcode dart flutter

我已经经历这个错误很长时间了。我已尽力按照网上的解决方案来解决该问题,但似乎没有任何效果。下面是堆栈跟踪

Unable to install /Users/samuel/Desktop/Projects/flutter/ASPIRE/aspire/build/ios/iphonesimulator/Runner.app on F6FB781C-D7B0-40C0-8665-6E703C4F7A3C. This is sometimes caused by a malformed plist file:
ProcessException: Process exited abnormally:
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=22):
Failed to install the requested application
The application's Info.plist does not contain a valid CFBundleVersion.
Ensure your bundle contains a valid CFBundleVersion.
  Command: xcrun simctl install F6FB781C-D7B0-40C0-8665-6E703C4F7A3C /Users/samuel/Desktop/Projects/flutter/ASPIRE/aspire/build/ios/iphonesimulator/Runner.app
Error launching application on iPhone X.
Run Code Online (Sandbox Code Playgroud)

下面也是我的 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>
            NSCameraUsageDescription
        </key>
        <string>
            We need to access the camera
        </string>
        <key>
            NSPhotoLibraryUsageDescription
        </key>
        <string>
            We need to access your gallery
        </string>
        <key>
            CADisableMinimumFrameDurationOnPhone
        </key>
        <true />
        <key>
            CFBundleDevelopmentRegion
        </key>
        <string>
            $(DEVELOPMENT_LANGUAGE)
        </string>
        <key>
            CFBundleDisplayName
        </key>
        <string>
            Aspire
        </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>
            aspire
        </string>
        <key>
            CFBundlePackageType
        </key>
        <string>
            APPL
        </string>
        <key>
            CFBundleShortVersionString
        </key>
        <string>
            1.0.0
        </string>
        <key>
            CFBundleSignature
        </key>
        <string>
            ????
        </string>
        <key>
            CFBundleVersion
        </key>
        <string>
            $(FLUTTER_BUILD_NUMBER)
        </string>
        <key>
            LSRequiresIPhoneOS
        </key>
        <true />
        <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)

我尝试过的解决方案

  1. 更新 CFBundle 版本
  2. 扑干净
  3. 删除模拟器的内容并重新启动
  4. 在 xcode 中的 Runner/Identity/build 下设置内部版本号 xcode 中的内部版本号

先感谢您

小智 7

在 ios/Runner/info.plist 添加双引号

由此

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

<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSRequiresIPhoneOS</key>
Run Code Online (Sandbox Code Playgroud)

<key>CFBundleShortVersionString</key>
<string>"$(FLUTTER_BUILD_NAME)"</string>

<string>"$(FLUTTER_BUILD_NUMBER)"</string>
<key>LSRequiresIPhoneOS</key>
Run Code Online (Sandbox Code Playgroud)