Xcode 27 的 Validate App 卡在 Preparing:dwarfdump-classic "bad CPU type" 的解决办法
在 Apple 芯片 Mac 上,如果 xcrun 把 dwarfdump-classic 解析到旧的、仅支持 Intel 的 Command Line Tools 副本,而系统又没有安装 Rosetta,Xcode 27 的验证和上传可能会卡在 Preparing。将该副本移开,并选用 Xcode 即可解决。

如果在搭载 Xcode 27 的 Apple 芯片 Mac 上,Validate App、Distribute App 或 Transporter 一直停在 "Preparing",请检查 xcrun 是否把 dwarfdump-classic 解析到了 /Library/Developer/CommandLineTools 中旧的、仅支持 Intel 的副本。没有 Rosetta 时,这个二进制文件无法启动,而据开发者反馈,验证辅助程序不会报错,只会一直等待。把过时的 Command Line Tools 文件夹移开,并让 xcode-select 指向 Xcode 27;安装 Rosetta 可作为短期替代办法。
Apple 尚未公布根本原因。下面的诊断来自 Apple Developer Forums 上的开发者,而在那里回复的 DTS 工程师只是请提问者提交 bug 报告,并没有确认其中的机制。
卡住时是什么样子
反馈中的环境是 Apple 芯片上 macOS 27.0 搭配 Xcode 27.0 (27A266a)。归档、签名和 IPA 打包都能成功,随后 Organizer 停在某个进度阶段,且永远不会超时。开发者报告的阶段有 "Preparing…"、带有 "Analyzing app" 的 "Validating…",以及上传时的:
Preparing to upload [App].ipa
Xcode 界面中不会出现任何错误。Transporter 1.4.5 同样会卡住,对 IPA 运行 xcrun swinfo 也会卡住。有开发者提到,Xcode Cloud 上传同一个项目毫无问题,这说明问题出在本地工具链,而不是 App 本身。
只有亲自运行该工具时才会看到错误:
% /Library/Developer/CommandLineTools/usr/bin/dwarfdump-classic --help
zsh: bad CPU type in executable
原因
根据论坛上的反馈,Xcode 和 Transporter 在验证期间运行的 swinfo 辅助程序会请求 dwarfdump-classic。thread 847303 的发帖者称,Xcode 27 不再自带这个工具,因此查找会回退到位于 /Library/Developer/CommandLineTools 的独立 Command Line Tools。在受影响的 Mac 上,该文件夹里是一个仅含 x86_64 的副本,其中一例还是 2019 年的,由迁移助理带过来的。
以下两个有文档记载的平台事实解释了为什么现在才出现这个问题:
- Xcode 27 发行说明指出,Xcode 27 只能在 Apple 芯片 Mac 上安装和运行。
- macOS 27 发行说明指出,如果之前安装过 Rosetta,升级到 macOS 27.0 后不会自动恢复。
升级前能通过 Rosetta 运行的 Intel 专用二进制文件,现在完全无法启动。在这些反馈中,swinfo 不会暴露这个失败,只是一直等待。
如何确认是不是这个问题?
运行下面三条命令。以下预期输出来自thread 845212中一位开发者发布的内容。
xcode-select --print-path
# /Applications/Xcode.app/Contents/Developer
xcrun --find dwarfdump-classic
# /Library/Developer/CommandLineTools/usr/bin/dwarfdump-classic
file "$(xcrun --find dwarfdump-classic)"
# Mach-O 64-bit executable x86_64
注意,在那份报告中 xcode-select 已经指向 Xcode,但 xcrun 仍然在 Command Line Tools 中找到了该工具。如果 xcrun --find 落在 CommandLineTools 里,且 file 只列出 x86_64,那就是这个原因。在 xcrun 命令中加上 --verbose,可以查看查找的过程。
要检查是否存在 Rosetta,原发帖者查看了 /Library/Apple/usr/libexec/oah/ 中有没有 libRosettaRuntime。这个检查方法来自论坛,不是 Apple 文档。
解决办法:移开过时的 Command Line Tools 并选用 Xcode
下面的命令需要管理员密码。移动文件夹不会删除任何内容,因此之后可以放回去。
- 退出 Xcode 和 Transporter,并取消所有卡住的验证。
- 把旧的独立 Command Line Tools 移开:
sudo mv /Library/Developer/CommandLineTools /Library/Developer/CommandLineTools-old - 将 Xcode 27 设为当前的开发者目录。如果你的 Xcode 不在标准位置,请调整路径:
根据 Apple 文档,sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer--switch需要超级用户权限,并会影响这台 Mac 上的所有用户。你也可以在 Xcode > Settings > Locations 的 Command Line Tools 下选择 Xcode 版本。 - 清除
xcrun的查找缓存,让它重新解析工具。xcrun 的 man 手册(man xcrun)说明,--kill-cache会删除缓存,并使所有值重新缓存:xcrun --kill-cache - 重新打开 Xcode,再次归档并运行 Validate App。
thread 845212 中的开发者报告说,执行前两条命令后,swinfo 会返回 shell,不再卡住。随后重新归档,验证通过,显示 "Your app successfully passed all validation checks."
替代办法:安装 Rosetta
安装 Rosetta 后,旧的二进制文件就能运行;thread 847303 的发帖者就是把它与上面的移动操作配合使用的。Apple 支持文档给出了终端命令,Mac 必须处于联网状态:
softwareupdate --install-rosetta
请把它当作权宜之计。同一篇 Apple 支持文档指出,从 macOS 28 开始,Rosetta 将只适用于部分依赖 Intel 框架的旧游戏。届时,构建路径上的 Intel 专用工具会再次出问题。
如何确认已经解决?
xcrun --find dwarfdump-classic不再返回/Library/Developer/CommandLineTools内的路径。如果当前使用的 Xcode 中没有这个工具,它也可能返回错误。xcrun swinfo会返回提示符,不再卡住。在 thread 845212 中,它随后打印了另一个bitcode-build-tool内部错误,但 Organizer 验证仍然成功。- Organizer 越过 "Preparing",要么验证通过,要么报告真正的错误。
其他情况和边界情形
- 过时的
~/.itmstransporter文件夹。在 thread 845212 中,一位遇到同样卡住问题的开发者删除了~/.itmstransporter后问题消失,该文件夹里是 2018 年和 2019 年的 Transporter 文件。如果想保留退路,建议重命名而不是删除。 - 你仍然需要独立的 Command Line Tools。移开旧文件夹后,用
xcode-select --install或软件更新安装最新的软件包,用pkgutil --pkg-info=com.apple.pkg.CLTools_Executables检查,然后再次运行xcrun --find dwarfdump-classic和file,确认查找路径上没有重新出现仅含 x86_64 的副本。 - 彻底删除旧副本。Apple 文档记载的命令是
sudo rm -rf /Library/Developer/CommandLineTools。这会永久删除该文件夹。若要避免软件更新再次推送该软件包,Apple 文档记载的命令是sudo pkgutil --forget com.apple.dt.commandlinetools。 - 上传仍然被阻塞。在thread 847720中,Organizer 上传卡住的开发者改用 Xcode Cloud,或在终端运行
xcrun iTMSTransporter -m upload完成发布(发布该命令的开发者还传入了-assetFile(IPA 路径)、-u(Apple ID)、-p(专用密码)和-itc_provider(提供者简称))。 - 另一种 swinfo 故障。在 thread 847720 中,原发帖者转述了一个 AI 编程助手给出的未经验证的诊断:
swinfo是崩溃(SIGSEGV,退出码 139),而不是在等待dwarfdump-classic。如果xcrun --find dwarfdump-classic没有指向CommandLineTools,这个办法很可能不适用;请使用上面的上传替代方案。 - Transporter 崩溃。thread 847303 还报告了 Transporter 1.4.5 在 macOS 27.0 上绘制活动队列时崩溃。这看起来是另一个独立的 bug。
如何在构建用 Mac 上预防
- 迁移 Mac 或升级 macOS 之后,对
/Library/Developer/CommandLineTools/usr/bin/dwarfdump-classic运行file。如果只显示x86_64,按上文所述把整个文件夹移开。如果之后需要独立工具,请安装最新的 Command Line Tools,并再次运行同样的 file 检查。 - Apple 建议每次升级 macOS 之后都检查是否有新版 Command Line Tools,因为已安装的版本可能与新的 macOS 不兼容。
- 在自托管的构建机器上,用
xcode-select --switch或DEVELOPER_DIR明确设置开发者目录,并把xcrun --find dwarfdump-classic检查加入你的配置脚本。 - 不要在发布工具链中依赖 Rosetta。macOS 27 升级不会恢复它,而在 macOS 28 中它的适用范围也受到限制。
资料来源
- Apple Developer Forums: Xcode 27 Validate App and Upload hang at Preparing
- Apple Developer Forums: Xcode 27 RC App Store Connect validation/upload hangs
- Apple Developer Forums: Xcode 27.0 RC hangs at Preparing to upload
- Apple Developer Documentation: Installing the command-line tools
- Apple Developer Documentation: Configuring command-line tools settings
- Apple Developer Documentation: macOS 27 Golden Gate Release Notes
- Apple Developer Documentation: Xcode 27 Release Notes
- Apple Support: Using Intel-based apps on a Mac with Apple silicon


