解决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版本发现还是以前的版本,可以先尝试卸载旧版本再重新安装。

相关推荐
里欧跑得慢20 小时前
Flutter 测试全攻略:从单元测试到集成测试的完整实践
前端·css·flutter·web
90后的晨仔20 小时前
第2章:声明式 UI 基础
ios
90后的晨仔21 小时前
SwiftUI 与开发环境简介
ios
键盘鼓手苏苏1 天前
Flutter 三方库 pip 的鸿蒙化适配指南 - 实现标准化的画中画(Picture-in-Picture)模式、支持视频悬浮窗与多任务并行交互
flutter·pip·harmonyos
左手厨刀右手茼蒿1 天前
Flutter 组件 sheety_localization 的适配 鸿蒙Harmony 实战 - 驾驭在线协作式多语言管理、实现鸿蒙端动态词条下发与全球化敏捷发布方案
flutter·harmonyos·鸿蒙·openharmony·sheety_localization
见山是山-见水是水1 天前
鸿蒙flutter第三方库适配 - 路由书签应用
flutter·华为·harmonyos
火柴就是我1 天前
记录一些跨平台开发需要的鸿蒙知识
flutter·harmonyos
Tong Z1 天前
Flutter中的三种通道
flutter
Ox8BADFOOD1 天前
Xcode 26.4 下老项目与 Pod 兼容性修复指南
ios
空中海1 天前
2.3 组件复用与组合
flutter·dart