升级Xcode 15后构建iOS应用报错:DT_TOOLCHAIN_DIR无法评估LIBRARY_SEARCH_PATHS
解决Xcode 15构建iOS应用时DT_TOOLCHAIN_DIR错误的方案
核心原因
Xcode 15废弃了DT_TOOLCHAIN_DIR环境变量,改用TOOLCHAIN_DIR,你用到的objectbox_flutter_libs: ^2.2.1和firebase_core: ^2.16.0版本配置中仍在使用旧变量,导致构建失败。
具体解决方法
方法1:升级依赖到兼容版本
- objectbox_flutter_libs:升级至>=2.10.0版本(该版本已修复Xcode 15适配问题)
- firebase_core:升级至>=2.19.0版本(Firebase官方在该版本后完成Xcode 15适配)
执行命令更新依赖:
flutter pub upgrade objectbox_flutter_libs firebase_core
方法2:临时修改Podfile适配(无法升级依赖时用)
在iOS目录下的Podfile末尾添加以下代码,强制替换变量:
post_install do |installer| installer.pods_project.targets.each do |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
添加后重新安装Pod:
cd ios && pod install --repo-update
方法3:清除构建缓存(上述方法无效时尝试)
- 清除Flutter缓存:
flutter clean - 清除Pod缓存:
cd ios && pod deintegrate && pod cache clean --all - 重新初始化依赖:
flutter pub get && cd ios && pod install
内容的提问来源于stack exchange,提问作者Preem Palver2
相关产品推荐
相关产品推荐

