Resolving "DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS" in Xcode 15
Problem Statement
After updating Xcode to version 15 (with macOS Sonoma), many developers encounter build errors such as:
Common error messages include:
Firebase - DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead
FirebaseAnalytics - DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead
GoogleMLKit - DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead
This issue occurs because Xcode 15 replaces the DT_TOOLCHAIN_DIR
environment variable with TOOLCHAIN_DIR
. Projects or pods referencing the old variable cause build failures, typically affecting:
- Firebase-related modules
- CocoaPods dependency management
- Flutter iOS builds
- Legacy projects migrated from Xcode 14
Recommended Solutions
Primary Solution: Update CocoaPods
The most reliable fix is updating CocoaPods to v1.13.0+. This version includes a patch for Xcode 15 compatibility.
Steps:
Update CocoaPods:
bashsudo gem update cocoapods # Alternatively with Homebrew: brew upgrade cocoapods
Verify installation:
bashpod --version # Should show 1.13.0+
Clean project artifacts:
bashcd ios flutter clean # For Flutter projects rm Podfile.lock rm -rf Pods/
Reinstall dependencies:
bashflutter pub get # Flutter projects only pod install pod update # Recommended to refresh pods
Clean build folder in Xcode (Product > Clean Build Folder)
Alternative Solution: Add Podfile Script (Temporary Fix)
If updating CocoaPods doesn't resolve the issue immediately, add a post_install
hook to your Podfile
:
post_install do |installer|
installer.pods_project.targets.each do |target|
# Flutter projects only: keep this line
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
next unless config.base_configuration_reference
xcconfig_path = config.base_configuration_reference.real_path
xcconfig = File.read(xcconfig_path)
xcconfig_mod = xcconfig.gsub('DT_TOOLCHAIN_DIR', 'TOOLCHAIN_DIR')
File.write(xcconfig_path, xcconfig_mod)
end
end
end
Apply the script:
- Run
pod install
- Perform a full rebuild (Shift-Command-K to clean)
Additional Troubleshooting Steps
For persistent issues:
Manual search/replace:
In Xcode, openFind > Find and Replace in Workspace
and replace allDT_TOOLCHAIN_DIR
withTOOLCHAIN_DIR
.Update iOS deployment target:
Ensure your Podfile specifies a minimum iOS version ≥ 13.0:rubypost_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0' end end end
Flutter-specific fixes:
- Upgrade problematic packages (e.g.,
flutter_inappwebview
to v5.8.0+) - Run:bash
flutter clean && flutter pub get cd ios pod install
- Upgrade problematic packages (e.g.,
Explanation
- Apple deprecated
DT_TOOLCHAIN_DIR
in Xcode 15's build system, replacing it withTOOLCHAIN_DIR
. - Older CocoaPods versions (pre-1.13.0) hardcode
DT_TOOLCHAIN_DIR
, causing LIBRARY_SEARCH_PATHS evaluation failures. - Updating CocoaPods resolves this permanently by patching internal references, while the Podfile script provides an immediate search-and-replace workaround.
- Flutter projects require special handling due to additional build settings injected by the Flutter toolchain.
Important
Avoid manually editing pod configuration files unless necessary. If updating CocoaPods doesn't resolve your issue automatically, the temporary script solution should be used as an interim measure until library owners update their dependencies.