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

如何修复无效CFBundleVersion错误?Flutter iOS安装失败排查

如何修复iOS模拟器安装时的CFBundleVersion无效问题

我已知晓该错误产生的原因,但问题仍未解决。以下是我遇到的报错信息,请问该如何修复?

Xcode build done.                                           139.7s
Unable to install /Users/ljsharp/Downloads/gsl_dictionary/build/ios/iphonesimulator/Runner.app on 69287A0D-7119-413E-AF7E-C608ADF7B106. This is sometimes caused by a malformed plist file:
ProcessException: Process exited abnormally:
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=22):
Simulator device returned an error for the requested operation.
The application's Info.plist does not contain a valid CFBundleVersion.
Ensure your bundle contains a valid CFBundleVersion.
Underlying error (domain=NSPOSIXErrorDomain, code=22):
    Failed to install the requested application
    The application's Info.plist does not contain a valid CFBundleVersion.
  Command: xcrun simctl install 69287A0D-7119-413E-AF7E-C608ADF7B106 /Users/ljsharp/Downloads/gsl_dictionary/build/ios/iphonesimulator/Runner.app
Error launching application on iPhone 14 Pro Max.
Exited

Info.plist相关截图

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>CFBundleName</key>
    <string>gsl_dictionary</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>$(FLUTTER_BUILD_NAME)</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>$(FLUTTER_BUILD_NUMBER)</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>

修复方案

  • 检查pubspec.yaml版本配置
    打开Flutter项目根目录的pubspec.yaml,确认version字段格式正确,必须是x.y.z+n的形式(比如version: 1.0.0+1),其中x.y.z对应FLUTTER_BUILD_NAME,n对应FLUTTER_BUILD_NUMBER,不能包含空格或特殊字符。

  • 修复Info.plist文件完整性
    你提供的Info.plist缺少闭合标签,在文件末尾添加以下内容,确保plist结构合法:

    </dict>
    </plist>
    
  • 替换变量为具体值测试
    暂时把Info.plist中的版本变量替换为固定值,比如:

    <key>CFBundleShortVersionString</key>
    <string>1.0.0</string>
    <key>CFBundleVersion</key>
    <string>1</string>
    

    重新构建安装,验证是否能正常运行。

  • 清理缓存并重新构建

    1. 执行flutter clean清理Flutter缓存
    2. 进入iOS目录,删除Pods文件夹和Podfile.lock
    3. 执行pod install重新安装依赖
    4. 重启Xcode和iOS模拟器,再尝试构建安装
  • 检查Xcode构建设置
    打开ios/Runner.xcworkspace,选中Runner目标,进入Build Settings:

    • 搜索Versioning,确认Current Project Version的值与pubspec.yaml中的+后数字一致
    • 确认Marketing Version的值与pubspec.yaml中的x.y.z部分一致

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.25 12:28:31