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

升级Xcode 15和macOS Sonoma后iOS项目构建报错的解决咨询

Xcode 15 + macOS Sonoma 构建iOS项目遇DT_TOOLCHAIN_DIR报错解决方案

升级至Xcode 15和macOS v14(Sonoma)后,构建原生iOS项目时出现以下报错,此前在Xcode 14中可正常构建:

  • Firebase - DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead
  • FirebaseAnalytics - DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead
  • GoogleMLKit - DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead

已尝试但未解决的方案:

  • 更新项目构建设置,手动将LIBRARY_SEARCH_PATHS中的DT_TOOLCHAIN_DIR替换为TOOLCHAIN_DIR
  • 执行pod update
  • 执行Clean Build后重新构建

有效解决方案

1. 通过Podfile钩子批量替换所有依赖的配置

在项目的Podfile末尾添加以下代码,执行pod install后会自动替换所有pod目标中的DT_TOOLCHAIN_DIR为TOOLCHAIN_DIR:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      xcconfig_path = config.base_configuration_reference.real_path
      xcconfig = File.read(xcconfig_path)
      xcconfig_modified = xcconfig.gsub("DT_TOOLCHAIN_DIR", "TOOLCHAIN_DIR")
      File.open(xcconfig_path, "w") { |file| file << xcconfig_modified }
    end
  end
end

2. 确保依赖版本支持Xcode 15

检查Podfile.lock中相关依赖的版本:

  • Firebase需升级至10.15.0及以上版本
  • GoogleMLKit需升级至4.0.0及以上版本

若版本不符,可在Podfile中指定版本后执行pod update,例如:

pod 'Firebase/Analytics', '~> 10.15.0'
pod 'GoogleMLKit/TextRecognition', '~> 4.0.0'

3. 重置Xcode派生数据

删除Xcode的派生数据后重新构建:

  • 打开Xcode,点击顶部菜单栏的Xcode -> Settings
  • 切换到Locations标签,点击Derived Data旁的箭头打开文件夹
  • 删除文件夹内所有内容,回到Xcode重新构建项目

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.09 06:00:09