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

相关推荐
Sindyue3 小时前
flutter项目老是卡在Running Gradle task ‘assembleRelease‘......
flutter
西西学代码3 小时前
Flutter---泛型
flutter
写不完的程序3 小时前
Flutter 3.38 版本发布了,看看有哪些新特性
flutter
Digitally5 小时前
如何在不使用iTunes的情况下在电脑上访问iPhone文件
ios·电脑·iphone
QuantumLeap丶5 小时前
《Flutter全栈开发实战指南:从零到高级》- 14 -网络请求与数据解析
flutter·ios·dart
RollingPin5 小时前
iOS 内存管理之 autoreleasePool
ios·内存管理·runtime·autoreleasepool
程序员老刘5 小时前
华为小米都在布局的多屏协同,其实Android早就有了!只是你不知道...
android·flutter
清凉夏日5 小时前
Flutter 国际化完整指南
前端·flutter
猫林老师6 小时前
Flutter for HarmonyOS开发指南(九):测试、调试与质量保障体系
flutter·wpf·harmonyos
猫林老师6 小时前
Flutter for HarmonyOS开发指南(五):性能调优与性能分析全攻略
flutter·华为·harmonyos