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

相关推荐
恋猫de小郭7 小时前
你还用 IDE 吗? AI 狂欢时代下 Cursor 慌了, JetBrains 等 IDE 的未来是什么?
前端·flutter·ai编程
TT_Close1 天前
🐟 发布中心进度同步:8 个商店的上传功能开发完毕,正抓紧测试
flutter·npm·visual studio code
RaidenLiu1 天前
Flutter Platform Channel 底层架构解析 —— 从 BinaryMessenger 到跨平台消息通信机制
前端·flutter·前端框架
开心就好20251 天前
iOS App 安全加固流程记录,代码、资源与安装包保护
后端·ios
开心就好20251 天前
iOS App 性能测试工具怎么选?使用克魔助手(Keymob)结合 Instruments 完成
后端·ios
鹏多多1 天前
Flutter使用screenshot进行截屏和截长图以及分享保存的全流程指南
android·前端·flutter
恋猫de小郭1 天前
什么 AI 写 Android 最好用?官方做了一个基准测试排名
android·前端·flutter
zhongjiahao2 天前
面试常问的 RunLoop,到底在Loop什么?
ios
勤劳打代码3 天前
Flutter 架构日记 — 状态管理
flutter·架构·前端框架
wvy3 天前
iOS 26手势返回到根页面时TabBar的动效问题
ios