Xcode 15打包Unity项目报错:无法检测到兼容的iPhoneOS SDK
使用Unity 2023.1.9f1导出项目后,通过Xcode 15归档打包时反复触发构建错误,错误提示如下:
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!
已确认未使用CocoaPods或Flutter,仅通过Xcode操作,且已在Xcode下拉菜单中选择CommandLineTools、通过Xcode主菜单安装SDK,但问题仍未解决。
检查Xcode的安装路径与命名规范
必须保证Xcode.app安装在/Applications目录下,且文件名符合Xcode*.app格式(推荐使用默认的Xcode.app,不要自定义命名为Xcode15.app这类特殊名称)。如果路径或命名不符合要求,移动或重命名后重启Xcode。重新指定xcode-select的路径
打开终端,先查看当前xcode-select指向的路径:xcode-select -p如果返回的不是
/Applications/Xcode.app/Contents/Developer,执行以下命令重新指定(需要输入系统密码):sudo xcode-select -s /Applications/Xcode.app/Contents/Developer完成后重启Xcode,再尝试构建归档。
验证iPhoneOS SDK是否存在
打开Finder,前往路径/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs,检查是否存在iPhoneOS.sdk相关文件(Xcode 15对应应为iPhoneOS17.0.sdk或更高版本)。如果缺失,打开Xcode的设置→平台,找到iOS选项点击「安装」重新下载SDK,安装完成后重启Xcode。核对Unity导出的SDK配置
在Unity的Build Settings中,切换到iOS平台,确认SDK版本设置为「Latest installed」,避免选择Xcode未安装的旧版SDK。设置完成后重新导出项目,再用Xcode打开尝试归档。清理Xcode缓存
关闭Xcode,执行终端命令清理DerivedData缓存:rm -rf ~/Library/Developer/Xcode/DerivedData重新打开Xcode后,按下
Command+Shift+K清理项目,再尝试归档操作。
内容的提问来源于stack exchange,提问作者Solar

