Error: DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead
Source: Dev.to
Problema
A partir de Xcode 15, el toolchain ya no se busca en la variable $DT_TOOLCHAIN_DIR sino en $TOOLCHAIN_DIR.
Al incluir una dependencia de CocoaPods, como Firebase, puede aparecer el siguiente error:
error: DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead (in target 'Firebase' from project 'Pods')
Solución
- Actualizar la dependencia que genera el error (por ejemplo, Firebase).
- Si no es posible actualizarla, buscar todas las ocurrencias de
$DT_TOOLCHAIN_DIRen los archivos del pod y reemplazarlas por$TOOLCHAIN_DIR.
Script de post‑instalación (CocoaPods)
Si solo una dependencia está provocando el error, se puede añadir el siguiente bloque post_install al Podfile:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
# Actualizar LIBRARY_SEARCH_PATHS
['Firebase.release.xcconfig', 'FirebaseAnalytics.release.xcconfig'].each do |file_name|
Dir.glob("Pods/**/#{file_name}", File::FNM_CASEFOLD).each do |xcconfig_path|
text = File.read(xcconfig_path)
new_contents = text.gsub('DT_TOOLCHAIN_DIR', 'TOOLCHAIN_DIR')
File.open(xcconfig_path, "w") { |file| file.puts new_contents }
end
end
end
end
end