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

18

131

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

Steal answered 3/10, 2023 at 4:21 Comment(1)
This issue has been fixed in CocoaPods version 1.13.0, as reported by Piero Ramos in his answer below.Lewls
B
193

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
    
Blimey answered 4/10, 2023 at 12:55 Comment(9)
what does flutter and AndroidStudio have to do with an Xcode problem?^^Launder
This issue has been fixed in CocoaPods version 1.13.0, as reported by Piero Ramos in his answer below.Lewls
solved my issue for capacitor, just ignored flutter stuffAccrual
for Cordova: swapped flutter clean for cordova clean and swapped flutter pub get for cordova prepare and skipped the part about Android Studio.Archangel
been struggling for weeks, finally fixed!Ennui
pod install is not needed, if you do pod updateChaparral
Excellently explained step-to-step guide, even though these steps take a huge amount of time. Thank you very much!Albion
sudo gem update cocoapods took like 20 min so be patient...Rubyeruch
Thanks a lot! It's exactly working.Shavian
K
89

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
Kesler answered 7/10, 2023 at 18:20 Comment(5)
None of the solution worked for me. :(Turbary
"For Flutter Developers" worked for me. Both IntelliJ (Flutter) and Xcode build successfully done!Inductee
MY iOS doesn't have such feild, it didn't work at allJoeljoela
For Flutter solution worked flawlessly. Use find "flutter_additional_ios_build_settings(target)" and replace it with the code below.Jewess
This worked for me with flutter tooLivvi
S
23

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

Superdominant answered 25/1 at 20:21 Comment(1)
This is great! I guess we should sometimes read the error message text before googling it. lolShick
U
19

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

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

Uranian answered 3/1 at 13:15 Comment(1)
Thank you! This worked for me! However, I'm not pretty sure why... Is this because a specific Firebase pod configuration? I'm developing for iOS 17.2, Xcode 15.2, Flutter 3.16Cradle
B
11

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.

Brezhnev answered 11/10, 2023 at 17:30 Comment(2)
I don't think you actually need pod update for such operations, since it's Flutter that manages versions of dependencies.Lough
To clarify "pod update" is safe to run on flutter, pod will update to the latest possible version according to podfile. Added a note to my post.Brezhnev
Q
8

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
Quiver answered 10/10, 2023 at 12:13 Comment(3)
It's a good practice to include explanations in your solution to help others understand what's happening under the hood.Kesler
You just copied already posted answer.Lough
Other answers has been edited. @LoughGershom
G
6

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

Gobetween answered 4/12, 2023 at 7:23 Comment(2)
Outstanding ....Shabbir
Even though I'm running XCode 15.2, the second part only did the trick for me. I didn't need to change my podfile. I always try first the easiest way to fix something, so "sudo gem update xcodeproj" + "pod cache clean --all" (that was very important) + "pod install" solved my problem. Thank you for the clue!Achromat
I
5

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.

Isotope answered 24/1 at 13:44 Comment(0)
T
2

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
Taille answered 24/11, 2023 at 6:11 Comment(0)
H
2

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

Hermanhermann answered 17/1 at 10:11 Comment(1)
Thank you for your interest in contributing to the Stack Overflow community. This question already has quite a few answers—including one that has been extensively validated by the community. Are you certain your approach hasn’t been given previously? (It seems to me to be repeating the core guidance from previous answers.) If so, it would be useful to explain how your approach is different, under what circumstances your approach might be preferred, and/or why you think the previous answers aren’t sufficient. Can you kindly edit your answer to offer an explanation?Campo
C
1

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
Christianachristiane answered 11/10, 2023 at 6:22 Comment(0)
C
1

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.

Carloscarlota answered 27/10, 2023 at 17:21 Comment(0)
A
1

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
Ardenardency answered 3/12, 2023 at 4:17 Comment(0)
B
0

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.

Bentlee answered 3/10, 2023 at 4:22 Comment(0)
A
0

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.

Anthology answered 9/11, 2023 at 6:33 Comment(0)
C
0

Please Change All Pods iOS Deployment Target ios Version

Certitude answered 14/1 at 16:19 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Detonation
H
0

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

Heinz answered 11/4 at 15:15 Comment(1)
This question has already received seventeen answers—including one with well over a hundred upvotes. What’s the value of adding a “maybe” answer when this has already been answered, and the answers have been validated by the community?Campo
I
0

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
Inhospitality answered 12/4 at 21:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.