Skip to content

Fixing "DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS" Error in Flutter with Xcode 15

Flutter, Xcode, CocoaPods, iOS Development, Mobile App Development2 min read

If you're a Flutter developer, you may have encountered an error when trying to run your app after updating to the latest Xcode version - particularly Xcode 15. The error message you might see is "DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead." This error is related to a change in Xcode, and it can disrupt your workflow. In this article, we will explore solutions to address this issue and get your Flutter app up and running smoothly. I saw it personally when I tried to compile a project with Firebase in it.

Understanding the Issue

The error message you're encountering, "DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead," is a result of a change introduced by Apple in Xcode 15. In this version of Xcode, Apple replaced the $DT_TOOLCHAIN_DIR variable with $TOOLCHAIN_DIR. This change affects projects and targets that previously relied on the old variable.

To fix this issue and ensure compatibility with the updated Xcode, you have several options to consider:

Solution 1: Upgrading CocoaPods

One of the solutions to address this issue is upgrading CocoaPods to version 1.13.0 or later. There are two methods to achieve this:

Using Homebrew

If you have Homebrew installed, you can use it to upgrade CocoaPods. Open your terminal and run the following command:

1brew upgrade cocoapods

Using RubyGems

If you don't have Homebrew, you can upgrade CocoaPods using RubyGems with the following command:

1sudo gem install cocoapods

Upgrading CocoaPods to a compatible version can help resolve the "DT_TOOLCHAIN_DIR" error and ensure that your Flutter project functions correctly.

Solution 2: Modifying Your Project

In case upgrading CocoaPods doesn't resolve the issue, you can manually modify your project by addressing references to $DT_TOOLCHAIN_DIR and replacing them with $TOOLCHAIN_DIR. Here's how you can do it:

  1. Open your Flutter project in your preferred text editor.

  2. Search for instances of $DT_TOOLCHAIN_DIR within your project files.

  3. Replace each occurrence of $DT_TOOLCHAIN_DIR with $TOOLCHAIN_DIR.

By manually making these changes, you ensure that your project references the updated variable, making it compatible with Xcode 15.

Solution 3: Automatically Updating the Podfile

If you're using CocoaPods in your Flutter project and prefer an automated solution, you can update the Podfile to automatically replace $DT_TOOLCHAIN_DIR with $TOOLCHAIN_DIR. Here's how to do it:

  1. Edit your Podfile to include the following script within the post_install block:
1post_install do |installer|
2 xcode_base_version = `xcodebuild -version | grep 'Xcode' | awk '{print $2}' | cut -d . -f 1`
4 installer.pods_project.targets.each do |target|
5 target.build_configurations.each do |config|
6 if config.base_configuration_reference && Integer(xcode_base_version) >= 15
7 xcconfig_path = config.base_configuration_reference.real_path
8 xcconfig =
9 xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")
10, "w") { |file| file << xcconfig_mod }
11 end
12 end
13 end

This script will automatically update your project to use $TOOLCHAIN_DIR and should resolve the error when working with CocoaPods.

In Closing

The "DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS" error in Flutter can be a roadblock when trying to run your app after updating to Xcode 15. However, by upgrading CocoaPods, manually modifying your project, or automatically updating the Podfile, you can resolve this issue and continue developing your Flutter app with the latest Xcode. These solutions ensure your project is compatible with the changes introduced in Xcode 15, allowing you to focus on your app's development and functionality!