主要問題
在 Unity 中使用 IL2CPP Build iOS 專案時,發生以下錯誤:
Command PhaseScriptExecution failed with a nonzero exit code
子問題
Unity 無法偵測到可用的 iPhoneOS SDK,即使 Xcode 已正確安裝並且可以正常使用:
相關報錯:
Unity.IL2CPP.Bee.BuildLogic.ToolchainNotFoundException: IL2CPP C++ code builder is unable to build C++ code. In order to build C++ code for Mac, you must have Xcode installed.
Building for Apple Silicon requires Xcode 9.4 and Mac 10.12 SDK.
Xcode needs to be installed in the /Applications directory and have a name matching Xcode*.app. Or be selected using xcode-select.
It's also possible to use /Library/Developer/CommandLineTools if those match the listed requirements.
More information and installation instructions can be found here:
https://developer.apple.com/support/xcode/
Specific Xcode versions can be downloaded here:
https://developer.apple.com/download/more/
Unable to detect any compatible iPhoneOS SDK!
錯誤訊息 - 詳細內容
找不到 bee_backend chmod: /Users/vaunicacalji/Desktop/DinoKite/Il2CppOutputProject/IL2CPP/build/deploy_x86_64/bee_backend/mac-x86_64/bee_backend: No such file or directory
➡ 問題:手動檢查時,bee_backend 確實存在,且可以執行,但 Build 時仍然報錯找不到。
IL2CPP 錯誤 Build failed with 0 successful nodes and 0 failed ones
Error: Internal build system error. BuildProgram exited with code 1.
Xcode 無法被 Unity 偵測 Unable to detect any compatible iPhoneOS SDK!
➡ 問題:但 xcode-select -p 確認 Xcode 安裝於 /Applications/Xcode.app/Contents/Developer,並且 xcodebuild -showsdks 列出了可用的 iOS SDK (18.2)。
Xcode 版本確認 xcodebuild -version 顯示:
Xcode 16.2 (Build version 16C5032a)
可用的 SDK xcodebuild -showsdks 顯示:
iOS 18.2 -sdk iphoneos18.2 ✅
環境資訊
macOS 版本:Sonoma 14.5
Mac 型號:MacBook Air (Retina, 13 英寸, 2018 年)
處理器:1.6 GHz 雙核心 Intel Core i5
記憶體:8GB 2133 MHz LPDDR3
顯示卡:Intel UHD Graphics 617 1536MB
Unity 版本:2022.2.21f1
已安裝的 Unity 模組:
✅ iOS Build Support
✅ Mac Build Support (IL2CPP)
✅ IL2CPP
目前狀況
✅ Xcode 已正確安裝,xcode-select -p 顯示正確路徑
✅ xcodebuild -showsdks 顯示可用的 iOS SDK (iOS 18.2)
✅ bee_backend 在手動檢查時存在且可執行
❌ 但 Build iOS 專案時仍然報錯 Unable to detect any compatible iPhoneOS SDK!
❌ 導致無法成功 Build iOS 專案
請問如何解決?
附上xcode中的build setting
ALWAYS_SEARCH_USER_PATHS = NO
ARCHS = arm64
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon
CLANG_CXX_LANGUAGE_STANDARD = c++0x
CLANG_CXX_LIBRARY = libc++
CLANG_ENABLE_OBJC_ARC = YES
CODE_SIGN_IDENTITY[sdk=iphoneos*] = iPhone Distribution
CODE_SIGN_IDENTITY[config=Debug] = Apple Development
CODE_SIGN_IDENTITY[config=Release] = Apple Distribution
CODE_SIGN_STYLE = Manual
DEVELOPMENT_TEAM[sdk=iphoneos*] = 4429TL28T7
IPHONEOS_DEPLOYMENT_TARGET = 15.6
LD_RUNPATH_SEARCH_PATHS = $(inherited) @executable_path/Frameworks
PRODUCT_BUNDLE_IDENTIFIER = com.torihiplay.DinoKite
PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*] = DinoKite.
SDKROOT = iphoneos
SUPPORTED_PLATFORMS = iphoneos
TARGETED_DEVICE_FAMILY = 1,2
UNITY_RUNTIME_VERSION = 2022.2.21f1
UNITY_SCRIPTING_BACKEND = il2cpp
*要做正式發行版的-謝謝大家