You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter iOS报错:Info.plist无有效CFBundleVersion求解决方案

Flutter iOS 模拟器安装失败:CFBundleVersion 无效问题

错误栈信息

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.

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>

已尝试的解决方法

  • 更新CFBundleVersion
  • 执行flutter clean
  • 清空模拟器内容并重启
  • 在Xcode的Runner/Identity/build中设置版本号

有效解决方案

  • 检查pubspec.yaml的version字段:确保格式为x.y.z+build_number(例如1.0.0+1),Flutter会自动将+后的数值作为FLUTTER_BUILD_NUMBER注入Info.plist,缺失或格式错误会导致变量无法替换。
  • 硬编码CFBundleVersion:临时将Info.plist中$(FLUTTER_BUILD_NUMBER)替换为具体数值(如<string>1</string>),重新构建验证是否解决问题。
  • 检查Xcode构建设置:打开ios/Runner.xcworkspace,进入Runner target的Build Settings,搜索Versioning,确认Current Project Version为合法数值(如1),且Versioning System设置为Apple Generic。
  • 彻底清理构建缓存:删除ios/build目录,执行flutter clean && flutter pub get,再重新运行项目。
  • 匹配模拟器系统版本:确认Xcode中Runner target的Deployment Info里的iOS版本,与模拟器的系统版本一致,不一致则调整模拟器版本或项目部署目标。

内容的提问来源于stack exchange,提问作者Samuel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.06 00:05:34