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

相关推荐
YungFan1 小时前
SwiftUI-MLX本地大模型开发(三)
ios·llm·swiftui
顾林海2 小时前
Flutter容器组件深度解析
android·前端·flutter
xq95272 小时前
mac os flutter 配置环境变量
flutter
请叫我飞哥@2 小时前
Apple ID授权登入
ios·swiftui
weixin_452093256 小时前
关于apple ios苹果mdm监管锁的漏洞与修复
ios
sg_knight6 小时前
Flutter性能优化终极指南:从JIT到AOT的深度调优
前端·flutter·性能优化·web·dart
zonda的地盘8 小时前
[Get 源码] GetPageRoute 与 GetxController 的自动回收机制
flutter
明似水9 小时前
Flutter iOS 项目中 VolumeControllerPlugin 报错解决方案
flutter·ios
折翅鵬9 小时前
Flutter报错:Warning: CocoaPods is installed but broken
flutter·cocoapods
pengyu10 小时前
【Flutter 状态管理 - 壹】 | 提升对声明式编程的认知
android·flutter·dart