— Flutter, Xcode, CocoaPods, iOS Development, Mobile App Development — 2 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.
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:
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:
If you have Homebrew installed, you can use it to upgrade CocoaPods. Open your terminal and run the following command:
1brew upgrade cocoapods
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.
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:
Open your Flutter project in your preferred text editor.
Search for instances of $DT_TOOLCHAIN_DIR
within your project files.
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.
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:
post_install
block:1post_install do |installer|2 xcode_base_version = `xcodebuild -version | grep 'Xcode' | awk '{print $2}' | cut -d . -f 1`3
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) >= 157 xcconfig_path = config.base_configuration_reference.real_path8 xcconfig = File.read(xcconfig_path)9 xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")10 File.open(xcconfig_path, "w") { |file| file << xcconfig_mod }11 end12 end13 end14end
This script will automatically update your project to use $TOOLCHAIN_DIR
and should resolve the error when working with CocoaPods.
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!