解决Xcode15报错:DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS

出现场景

更新了一些三方库,升级了Xcode, 编译IOS出现以下错误。

shell 复制代码
Failed to build iOS app
Could not build the precompiled application for the device.
Error (Xcode): DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead

出现场景

这是Cocoapos老版本的一个bug,主要是在更新了Xcode15之后编译ios产生的问题。有两种解决方法。更新Cocoapods版本或者修改Podfile文件配置.

解决方案

修改Podfile

Podfile 复制代码
post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    # 新增以下内容
    target.build_configurations.each do |config|
      xcconfig_path = config.base_configuration_reference.real_path
      xcconfig = File.read(xcconfig_path)
      xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")
      File.open(xcconfig_path, "w") { |file| file << xcconfig_mod }
    end
  end
end

更新Cocoapos

更新cocoapos版本到1.13.0以上

shell 复制代码
$ sudo gem install cocoapods

更新完成后查看版本号

shell 复制代码
$ pod --version
1.15.2

如果更新后查看pod版本发现还是以前的版本,可以先尝试卸载旧版本再重新安装。

相关推荐
用户965597361905 小时前
Provider vs Bloc vs GetX vs Riverpod:Flutter 状态管理方案怎么选?
flutter
恋猫de小郭5 小时前
Flutter Patchwork,不用 Fork 改依赖包源码的第三方工具
android·前端·flutter
程序员老刘15 小时前
跑分第一的编程大模型,我为啥不用?
flutter·ai编程·vibecoding
恋猫de小郭1 天前
苹果 AirPods 协议,Android 也可以使用完整版 AirPods 能力
android·前端·flutter
张风捷特烈1 天前
Flutter 类库大揭秘#01 | path_provider架构与设计
android·flutter
壹方秘境3 天前
我用Go语言开发了一个跨平台的HTTPS抓包和调试工具
前端·后端·ios
恋猫de小郭4 天前
Android 限制侧载新进展,谷歌联合国内厂商推验证计划
android·前端·flutter
恋猫de小郭4 天前
解读 Android 17 全新内存限制,有没有“豁免”后门?
android·前端·flutter
程序员老刘6 天前
跨平台开发地图 | 2026年6月
flutter·ai编程·客户端
悟空瞎说7 天前
Flutter 架构详解:新手必懂底层原理
flutter