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

Unity开发iOS游戏在Xcode15构建失败:Command PhaseScriptExecution非零退出码

解决Unity在Xcode 15中构建iOS游戏时的IL2CPP工具链及SDK检测错误

错误信息

Showing Recent Messages
Unity.IL2CPP.Bee.BuildLogic.ToolchainNotFoundException: IL2CPP C代码构建器无法编译C代码。要在Mac上编译C++代码,必须安装Xcode。

针对Apple Silicon构建需要Xcode 9.4及Mac 10.12 SDK。

Xcode需安装在/Applications目录下,名称需匹配Xcode*.app格式,或通过xcode-select指定。

也可使用/Library/Developer/CommandLineTools,前提是其满足上述要求。

Showing Recent Messages
无法检测到任何兼容的iPhoneOS SDK!

at Unity.IL2CPP.Bee.BuildLogic.iOS.iOSBuildLogic.GetCompatibleXcodeInstallation(Architecture architecture, Version xcodeMinVersion, Version platformSdkMinVersion, Identifier platformSdkIdentifier, XcodePlatformSdk& compatiblePlatformSdk, XcodeInstallation& compatibleXcodeInstallation)

at Unity.IL2CPP.Bee.BuildLogic.iOS.iOSBuildLogic.UserAvailableToolchainFor(Architecture architecture, NPath toolChainPath, NPath sysRootPath)

at Unity.IL2CPP.Bee.IL2CPPExeCompileCppBuildProgram.BuildProgram.Main(String[] args, String currentDirectory)

at Unity.IL2CPP.Building.InProcessBuildProgram.StartImpl(String workingDirectory, String[] arguments) in /Users/bokken/build/output/unity/il2cpp/Unity.IL2CPP.Building/InProcessBuildProgram.cs:line 51


解决方案

  • 确认Xcode安装路径与命名规则
    确保Xcode安装在/Applications目录下,命名符合Xcode*.app格式(比如Xcode.app或Xcode15.app)。如果Xcode安装在自定义路径,需通过终端指定工具链路径:

    sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
    

    替换命令中的路径为你的Xcode实际安装路径。

  • 验证Command Line Tools配置

    1. 终端执行xcode-select -p,检查输出是否指向Xcode的Developer目录(而非单独的Command Line Tools)。
    2. 若配置错误,执行上述xcode-select命令切换;也可在Xcode中操作:Xcode > 设置 > 位置 > 命令行工具,选择对应Xcode版本。
  • 检查iPhoneOS SDK是否存在

    1. 打开Xcode,进入Xcode > Settings > Platforms,确认iOS平台已安装对应SDK。若未安装,点击"+"添加或在Preferences > Components中下载最新iOS SDK。
    2. 终端执行以下命令验证SDK文件:
    ls /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/
    

    需确保输出中存在iPhoneOS*.sdk格式的文件。

  • 确认Unity与Xcode版本兼容性
    确保使用的Unity版本支持Xcode 15,例如Unity 2022.3.8f1及以上LTS版本对Xcode 15有完善支持。若Unity版本过旧,建议升级至兼容版本。

  • 重置IL2CPP缓存
    在Unity编辑器中,依次点击Edit > Preferences > External Tools,找到IL2CPP相关选项,点击"Clear IL2CPP Cache",完成后重新构建项目。


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.07 04:10:20