如何修复无效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内容
<?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>重新构建安装,验证是否能正常运行。
清理缓存并重新构建
- 执行
flutter clean清理Flutter缓存 - 进入iOS目录,删除
Pods文件夹和Podfile.lock - 执行
pod install重新安装依赖 - 重启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
相关产品推荐
相关产品推荐

