Flutter项目iOS构建失败求助:CodeSign报错无法启动模拟器应用
Flutter iOS构建失败:Command CodeSign failed with nonzero exit code
执行flutter run启动iPhone 15 Pro Max模拟器调试时,iOS应用构建失败,报错信息如下:
Launching lib/main.dart on iPhone 15 Pro Max in debug mode... Running Xcode build... Xcode build done. 2.1s Failed to build iOS app **Uncategorized (Xcode): Command CodeSign failed with a nonzero exit code Could not build the application for the simulator. Error launching application on iPhone 15 Pro Max.**
已尝试的操作:
- 更新Flutter至最新版本
- 升级系统到macOS Sonoma 14.0
- 多次重启Mac
- 卸载并重装Xcode及iOS Simulator
修复步骤
- 检查Xcode签名配置
打开项目ios目录下的Runner.xcworkspace,在Xcode中选中Runner target,进入Signing & Capabilities标签页:- 勾选
Automatically manage signing - 确认Team选择了有效的开发者账号(个人/团队账号)
- 若模拟器调试仍失败,可暂时取消自动签名,手动选择
Signing Certificate为Apple Development,对应选择匹配的Provisioning Profile
- 勾选
- 清理Xcode签名缓存
执行以下命令删除缓存文件:
重启Xcode后重新构建项目rm -rf ~/Library/Developer/Xcode/DerivedData rm -rf ~/Library/MobileDevice/Provisioning\ Profiles - 清理Flutter项目缓存
依次执行命令:flutter clean flutter pub get flutter run - 修正Xcode命令行工具路径
执行xcode-select -p查看当前路径,若未指向Xcode的CommandLineTools,执行:sudo xcode-select -s /Applications/Xcode.app/Contents/Developer - 验证钥匙串证书有效性
打开钥匙串访问,确认Apple Development证书状态正常(无红叉标记),若证书失效,前往Apple开发者中心重新下载安装证书
内容的提问来源于stack exchange,提问作者Matei Dumitrescu
相关产品推荐
相关产品推荐

