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

相关推荐
程序员Ctrl喵4 小时前
渲染流水线:从代码到像素的“非凡旅程”
flutter
王码码20356 小时前
Flutter for OpenHarmony:es_compression — 高性能 Brotli 与 Zstd 算法实战
算法·flutter·elasticsearch
左手厨刀右手茼蒿6 小时前
Flutter 三方库 build_modules 的鸿蒙化适配指南 - 在鸿蒙系统上构建极致、模块化的 Dart 代码编译策略与构建流水线系统
flutter·harmonyos·鸿蒙·openharmony·build_modules
毛骗导演6 小时前
万字解析 OpenClaw 源码架构-跨平台应用之 iOS 应用
前端·ios·架构
songgeb7 小时前
Buildable Folder & Group & Folder Reference in Xcode
xcode·swift
鹏多多.16 小时前
Flutter使用screenshot进行截屏和截长图以及分享保存的全流程指南
android·前端·flutter·ios·前端框架
LawrenceLan16 小时前
37.Flutter 零基础入门(三十七):SnackBar 与提示信息 —— 页面反馈与用户交互必学
开发语言·前端·flutter·dart
少云清16 小时前
【UI自动化测试】1_IOS自动化测试 _环境搭建
ui·ios
ITKEY_18 小时前
macOS安装fvm管理flutter版本
flutter·macos
yijianxiangde10021 小时前
iOS 无根越狱前期准备
ios