DEV Community

Cover image for How to fix the error: DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead
Herlandro Hermogenes
Herlandro Hermogenes

Posted on

How to fix the error: DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead

In Xcode 15, Apple made a modification to the variable that points to the default toolchain location, replacing from $DT_TOOLCHAIN_DIR to $TOOLCHAIN_DIR. If your project or target relies on the previous variable, you should update it to use $TOOLCHAIN_DIR.

To perform this replacement, you can add the following code snippet at the end of your project’s Podfile. This error was on a MacOS v14 (Sonoma), XCode 15.4, Swift 5.0 regarding the Firebase and Firebase Analytics Pods.

Solution:
Add this code to your Podfile

# Solution for: macOS v14 (Sonoma) | XCode 15.4 | Swift 5.0 | PodFile

  post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|

  # Update the Swift version
      config.build_settings['SWIFT_VERSION'] = '5.0'

  # Update all Pods iOS Deployment Target ios Version
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '15.0'

    # Update 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
Enter fullscreen mode Exit fullscreen mode

and run

pod install

Top comments (0)