Flutter Xcode 15 Error (Xcode): DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS

Flutter Xcode 15 Error (Xcode): DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS


27

upon upgrading my Xcode today to version 15, I receive the following error when building my app for IOS:

Error (Xcode): DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead

It appears some specific dependencies are causing this issue, in my case:

  • objectbox_flutter_libs: ^2.2.1
  • firebase_core: ^2.16.0

I have no idea how to solve this issue, and I’ll really appreciate any advice!

Thanks!

3

  • 3

    This should be the fix: stackoverflow.com/a/77138033/1759443

    – Kyle Venn

    2 days ago

  • @Kyle Venn Giga chad

    – Preem Palver2

    2 days ago

  • @KyleVenn You are a man of honour and culture

    – Andre Pena

    yesterday

4 Answers
4


36

Add this code to your podfile

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

After that run a pod update (make sure that the iOS folder is the current directory before running pod update).

pod update

Solution 2: Issues while building iOS project with flutter

Check out this for multi flavour config.

Solution 3:
if you use inAppWebview for flutter then come error like this :

Parse Issue (Xcode): Could not build module ‘WebKit’

So you can add in Your pubspec.yaml file Like this:

flutter_inappwebview:
    git:
      url: https://github.com/Estrelio/flutter_inappwebview.git
      ref: fix-xcode-17  

Solution 4 (For non-flutter users):

Remove the below line from the script.

flutter_additional_ios_build_settings(target)

10

  • 1

    I tried this solution by @Kyle Venn and it indeed works. However, it's important to note that this should only be used as a temporary solution until the next cocopods update comes out.

    – Preem Palver2

    yesterday

  • This fails with: undefined method `real_path' for nil:NilClass. I have multiple flavours in my app, and this doesn't help with the issue.

    – Lukasz C.

    yesterday

  • 1

    I tried that solution but then I'm getting this when trying to run the app: Error (Xcode): 123 duplicate symbols Error (Xcode): Linker command failed with exit code 1 (use -v to see invocation)

    – Lukasz C.

    yesterday

  • 1

    @PreemPalver2 No, I cant "simply" delete the iOS folder. I have five big apps to support, and each has a complex and custom Xcode configuration. It would take me a week to recreate this. I often see this "simply delete" suggestion because people assume there is nothing in the ios folder, which often isn't the case for bigger apps. I'll have a look if setting an old linker helps.

    – Lukasz C.

    yesterday

  • 1

    btw, comment "flutter" line if you don't have flutter

    – pw2

    2 hours ago


3

Solution that worked for me: Xcode 15 with Flutter

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|
    flutter_additional_ios_build_settings(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

1

  • Build error with this change: 'undefined method xcconfigs' for #<Xcodeproj::Project::Object::PBXNativeTarget:0x000000014aa715c0>

    – Jimmy_m

    yesterday



2

Try this, its works in react-native:

    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


0

Try this,

find . -name "*.xcconfig" -type f -exec grep -l 'DT_TOOLCHAIN_DIR' {} ; 
| while IFS= read -r file; do sed -i '' 's/DT_TOOLCHAIN_DIR/TOOLCHAIN_DIR/g' "$file"; done

in my case I ran it in my project folder.

source: https://www.mongodb.com/community/forums/t/xcode-15-cocoapods/245603



Leave a Reply

Your email address will not be published. Required fields are marked *