Abhistin
Abhistin

Reputation: 1631

DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead in xcode 15

I am trying to build a native iOS project after upgrading to the latest Xcode 15 and macOS v14 (Sonoma). Earlier it was working fine in Xcode 14.

While Building the project, I am getting these errors:

  1. Firebase - DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead

  2. FirebaseAnalytics - DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead

  3. GoogleMLKit - DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead

How can I fix it?

I tried a few options on my own and will list those below.

  1. update the build settings in your Xcode project to use TOOLCHAIN_DIR instead of DT_TOOLCHAIN_DIR.

    • Open Your Xcode Project:
      Open your Xcode project that is experiencing the build errors.

    • Navigate to Build Settings:
      Navigate to the project or target's Build Settings.

    • Find LIBRARY_SEARCH_PATHS:
      Locate the LIBRARY_SEARCH_PATHS build setting.

    • Update DT_TOOLCHAIN_DIR:
      If you find any references to DT_TOOLCHAIN_DIR, update them to use TOOLCHAIN_DIR.

    • Replace DT_TOOLCHAIN_DIR with TOOLCHAIN_DIR:
      Replace DT_TOOLCHAIN_DIR with TOOLCHAIN_DIR in the build settings.

    • Save and Rebuild:
      Save your changes and attempt to rebuild your project.

  2. POD Update

  3. Clean Build and rebuild

Upvotes: 150

Views: 100095

Answers (21)

Nguyễn Quang
Nguyễn Quang

Reputation: 21

I had the same issue while installing Firebase in Xcode 15 and CocoaPods 1.12.1. Earlier CocoaPods version was working fine in Xcode 14.

So updating the CocoaPods version, and clearing the caches (optional) should solve this problem. Follow these steps:

  1. Update CocoaPods
sudo gem update cocoapods
  1. Reinstall dependencies via CocoaPods
pod install
  1. Clean build in Xcode with command
Shift-Command-K
  1. Run your target

Upvotes: 1

Mohammad mumtaz
Mohammad mumtaz

Reputation: 11

It is an issue due to the old CocoaPods version with Xcode 15. This is resolved in the CocoaPods version 1.15.2.

Please make sure to remember the following steps.

  1. Remove Any Existing CocoaPods Installation To prevent conflicts, let's start by cleaning up any existing installations of CocoaPods:
sudo gem uninstall cocoapods
brew uninstall cocoapods
  1. Ensure Homebrew and rbenv are Set Up Correctly Confirm that you have Homebrew and rbenv installed correctly. If not, you can install or update them using the commands below:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install rbenv ruby-build

After installing rbenv, add it to your shell:

echo 'eval "$(rbenv init -)"' >> ~/.zshrc  # or ~/.bash_profile for bash
source ~/.zshrc  # or source ~/.bash_profile
  1. Install the Correct Ruby Version Make sure you're using the correct Ruby version for your environment:
rbenv install 3.3.3  # or your preferred version
rbenv global 3.3.3
  1. Install CocoaPods Using gem Now, let's install CocoaPods using gem:
gem install cocoapods

Ensure that pod is in your PATH:

rbenv rehash
  1. Verify Installation Check if CocoaPods is installed correctly:
pod --version
  1. Edit Podfile and add them
  post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
      config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'
    end
  end
end
  1. Install Pods in Your iOS Project Navigate to your iOS directory and install the pods:
cd /path/to/your/flutter/project/ios
pod install

flutter clean flutter pub get cd ios pod install flutter run

Upvotes: 1

Chamara
Chamara

Reputation: 1

Do not try complex bypasses. You can just update cocoapods and it works fine. I have updated cocoapods to 1.15.2 from 1.12.1. Now issue is fixed automatically.

You can check your cocoapods version using pod --version. You can update it to latest using brew upgrade cocoapods.

Upvotes: 0

Arpit Patel
Arpit Patel

Reputation: 8047

For newbie IOS developer like me.

Go to Find -> Find and Replace in workspace

enter image description here

Press Replace ALL and then

IMPORTANT: Do not forget to save using CMD + S

Then clean the build.

Product -> Clean Build Folder and click run

Upvotes: 50

XiaotiL
XiaotiL

Reputation: 1

Encounter similar issue some time ago. Maybe can try to delete ${inheritance} in the Library search path in build settings.

Upvotes: 0

Tatti Vitorino
Tatti Vitorino

Reputation: 11

Just in case anyone needs I had the same issue with my flutter project and simply updating CocoaPods (in my case) to 1.15.2 fixed the problem..

gem install cocoapods 
flutter clean && flutter pub get
flutter run

Upvotes: 1

Vít Zadina
Vít Zadina

Reputation: 552

For me work update cocoapods, which fix problem with xCode 15.

Upgrade Cocoapods v1.13.0.

Brew command:

brew upgrade cocoapods

Without Brew:

sudo gem install cocoapods

Then run in your project/ios folder

pod install --repo-update

Note: If you can just migrate to package manager. Especially when you starting new project.

Upvotes: 5

Raj Kiran
Raj Kiran

Reputation: 21

Cocoapads needs to be updated for Xcode 15 to work. Go to terminal => your project => cd ios => sudo gem install cocoapods

Now go to Xcode -> Runner -> build Settings -> Check DT_TOOLCHAIN_DIR is replaced with TOOLCHAIN_DIR.If it is replaced, then it will work

Upvotes: 2

Praveen Kumar
Praveen Kumar

Reputation: 29

Please Change All Pods iOS Deployment Target ios Version

Upvotes: 0

Aviru
Aviru

Reputation: 109

When I tried to run a project whose pod is set up using Xcode 14.3 in Xcode 15.0, I faced the DT_TOOLCHAIN_DIR error. I solved it by the following:

  • I first removed the CocoaPods from the project and followed How to remove CocoaPods from a project?:

  • Cleared the DerievedData

  • I have written the below script at the end of podfile:

    post_install do |installer|
      installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
          config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
          xcconfig_path = config.base_configuration_reference.real_path
          xcconfig = File.read(xcconfig_path)
          xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")
          File.open(xcconfig_path, "w") { |file| file << xcconfig_mod }
        end
      end
    end
    
  • then used pod install.

This fixed my problem.

Similarly, in order to run the project whose pod is set up using Xcode 15.0 in Xcode 14.3, I used the below approach:

Note: You can use pod cache clean --all before pod install

Upvotes: 7

Agoo Clinton
Agoo Clinton

Reputation: 831

Navigate to and open with sudo with nano, sudo nano. Paste the path:

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.0.sdk/System/Library/Frameworks/WebKit.framework/Headers/WKWebsiteDataStore.h

Search for: __IPHONE_OS_VERSION_MAX_ALLOWED. Change it from 170000 to 180000.

Navigate to your pod file. Comment as commented below:

  # installer.generated_projects.each do |project|
  #   project.targets.each do |target|
  #     target.build_configurations.each do |config|
  #         config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
  #       end
  #   end
  # end

Then add this:

installer.pods_project.targets.each do |target|
  target.build_configurations.each do |config|
      if Gem::Version.new(config.build_settings['IPHONEOS_DEPLOYMENT_TARGET']) < Gem::Version.new('13.0')
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
      end
    end
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
    xcconfig_path = config.base_configuration_reference.real_path
    xcconfig = File.read(xcconfig_path)
    xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")
    File.open(xcconfig_path, "w") { |file| file << xcconfig_mod }
    end
  end
end

Upvotes: 1

Renegade
Renegade

Reputation: 802

For non-Flutter, or I should say for people code use native Swift in their projects. Adding the following snippet in my Podfile fixed it for me.

post_install do |installer|
    xcode_base_version = `xcodebuild -version | grep 'Xcode' | awk '{print $2}' | cut -d . -f 1`

    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            # For xcode 15+ only
            if config.base_configuration_reference && Integer(xcode_base_version) >= 15
                xcconfig_path = config.base_configuration_reference.real_path
                xcconfig = File.read(xcconfig_path)
                xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")
                File.open(xcconfig_path, "w") { |file| file << xcconfig_mod }
            end
        end
    end
end

I understand this is a temporary solution. The people who owns these pods are responsible for fixing this permanently.

Upvotes: 1

Piero Ramos
Piero Ramos

Reputation: 177

Updated 11 October 2023 Solutions If you faced this issue after updating to Xcode 15 and can't run your Flutter app on iOS platform.

Solution 1: Update CocoaPods to v1.13 (1.13 released a fix)

It seems to be an issue due to old CocoaPods version with Xcode 15. This is resolved in the CocoaPods version 1.13.0.

You can follow the steps above DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead in xcode 15.

Solution 2: Update Podfile (Flutter / Xcode 15)

However, it's important to note that this should only be used as a temporary solution until a CocoaPods update comes out that fixes your Xcode version.

post_install do |installer|
  installer.pods_project.targets.each do |target|
     flutter_additional_ios_build_settings(target)
      target.build_configurations.each do |config|
        xcconfig_path = config.base_configuration_reference.real_path
        xcconfig = File.read(xcconfig_path)
        xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")
        File.open(xcconfig_path, "w") { |file| file << xcconfig_mod }
      end
  end
end

For non-Flutter users: Remove the below line from the script.

flutter_additional_ios_build_settings(target)

Additional fixes related: Update Flutter libraries

If you use inAppWebview, an error like this will appear:

Parse Issue (Xcode): Could not build module 'WebKit'

Update inAppWebview to v5.8.0 release:

flutter_inappwebview: 5.8.0

Look for updates on the libraries you are using within your Flutter project.

Remember after using any of the above solutions

  1. Clean your Flutter project: flutter clean && flutter pub get
  2. Remove Pods directory inside the iOS directory: rm Podfile.lock && rm -rf Pods/
  3. Install and update pods: pod install && pod update
  4. Build and test your app on an iOS device: flutter run. Or build within your Xcode.

Note: "pod update" will update the pod to the latest version possible (as long as it matches the version restrictions in your Podfile), so it is safe to use on Flutter.

Upvotes: 12

Yiğit Kaan Atay
Yiğit Kaan Atay

Reputation: 106

It was solved after changing the podfile.

post_install do |installer|
  installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
      flutter_additional_ios_build_settings(target)
      xcconfig_path = config.base_configuration_reference.real_path
      xcconfig = File.read(xcconfig_path)
      xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")
      File.open(xcconfig_path, "w") { |file| file << xcconfig_mod }
      end
  end
end

Upvotes: 8

Abdullah
Abdullah

Reputation: 1606

In Xcode 15, Apple made a modification to the variable that points to the default toolchain location, replacing $DT_TOOLCHAIN_DIR with $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:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      xcconfig_path = config.base_configuration_reference.real_path
      xcconfig = File.read(xcconfig_path)
      xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")
      File.open(xcconfig_path, "w") { |file| file << xcconfig_mod }
    end
  end
end

After making this change in your Podfile, you will need to install the pods again via the terminal using the command:

pod install

For Flutter developers

To enhance your script's functionality, kindly insert the following line:

flutter_additional_ios_build_settings(target)

Here is the modified script with this addition:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
      xcconfig_path = config.base_configuration_reference.real_path
      xcconfig = File.read(xcconfig_path)
      xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")
      File.open(xcconfig_path, "w") { |file| file << xcconfig_mod }
    end
  end
end

Upvotes: 101

Shanmukha
Shanmukha

Reputation: 2574

This error occurs after updating Xcode to 15 because of some CocoaPods version, so updating it and flushing the caches should solve this problem.

Follow the steps below:

  1. Go to the ios/ folder

    cd ios
    
  2. Update CocoaPods

    sudo gem update cocoapods
    
  3. If the above doesn't work, try installing it through Homebrew

    brew install cocoapods
    
  4. Make sure CocoaPods updated to 1.13.0 or newer version (if available)

    pod --version
    
  5. Delete the build cache

    flutter clean
    
  6. Delete the Podfile.lock file

    rm Podfile.lock
    
  7. Delete the Pods/ folder as well

    rm -rf Pods/
    
  8. Install the Flutter package dependencies

    flutter pub get
    
  9. Install the iOS pod dependencies

    pod install
    
  10. Update your local pods

    pod update
    

Upvotes: 211

Prathap Ms
Prathap Ms

Reputation: 277

Go to pods → FirebaseSupport files, both .release and .debug files.

Change "DT_TOOLCHAIN_DIR" into "TOOLCHAIN_DIR instead". It works for me.

Upvotes: 24

hsiraaH
hsiraaH

Reputation: 35

This is due to CocoaPods. Please refer to this comment on the CocoaPods GitHub issue for the fix. It worked for me and many others who were mainly running native iOS projects, but some were also running hybrid projects.

Upvotes: 0

Mrudul Addipalli
Mrudul Addipalli

Reputation: 624

This is happening because of Xcode 15.

I reverted back to Xcode 14.2 or 14.3 by removing the 15 version and downloading the 14.2 xip file, and moved extracted Xcode to "Applications", without opening Xcode and creating Simulator with iOS <16... It worked for me.

Upvotes: 0

Akshay Kumar Karanam
Akshay Kumar Karanam

Reputation: 11

I followed these steps:

  1. Open terminal and run this command: sudo gem install cocoapods
  2. After installation, navigate to project folder and run this command: pod update

Upvotes: 2

Aravind Chowdary
Aravind Chowdary

Reputation: 150

Add the below lines to your Podfile and it will fix the issue. It renames all DT_TOOLCHAIN_DIR to TOOLCHAIN_DIR after pods are installed.

post_install do |installer|
  installer.aggregate_targets.each do |target|
    target.xcconfigs.each do |variant, xcconfig|
      xcconfig_path = target.client_root + target.xcconfig_relative_path(variant)
      IO.write(xcconfig_path, IO.read(xcconfig_path).gsub("DT_TOOLCHAIN_DIR", "TOOLCHAIN_DIR"))
    end
  end
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      if config.base_configuration_reference.is_a? Xcodeproj::Project::Object::PBXFileReference
        xcconfig_path = config.base_configuration_reference.real_path
        IO.write(xcconfig_path, IO.read(xcconfig_path).gsub("DT_TOOLCHAIN_DIR", "TOOLCHAIN_DIR"))
      end
    end
  end
end

Upvotes: 1

Related Questions