68

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!

4

13 Answers 13

89

UPDATE: This issue is resolved in the latest cocaopod version.

Command to upgrade: brew upgrade cocoapods

so if you install that you shouldn't need the solutions below:

Solution 1: 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
  • 2
    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. Sep 20 at 12:13
  • 2
    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.
    Sep 20 at 15:11
  • 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.
    Sep 21 at 4:23
  • 1
    Setting the linker combined with the other solution have worked. ;)
    – Lukasz C.
    Sep 21 at 10:39
  • 1
    btw, comment "flutter" line if you don't have flutter
    – pw2
    Sep 22 at 5:43
26

1.13.0 shipped with the fix.

Update Cocoapods to v1.13:

gem update cocoapods

Then in your ios project dir, run:

pod update
1
  • 2
    Even with version 1.13.0 I get these errors: Could not build module 'WebKit' /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.0.sdk/System/Library/Frameworks/WebKit.framework/Headers/WKWebsiteDataStore.h:120:47 type argument 'nw_proxy_config_t' (aka 'struct nw_proxy_config *') is neither an Objective-C object nor a block type Sep 23 at 20:42
7

For Flutter Devs and HomeBrew Users

A fix for this was released from the Cocoapods team

Github issue discussion here

Upgrade your Cocoapods to v1.13.0:

Run this command in your mac terminal

brew upgrade cocoapods

Check cocoapods version ensure v1.13.0

pod --version

Delete the Pods directory and Podfile.lock in your iOS module's root folder.

cd ios && rm -rf Pods && rm -rf Podfile. lock

Install pods

Run the below from the root of your iOS module

pod install

This should fix the error.

1
  • yep this worked for me! But I'm still running into another problem saying – Could not build module 'WebKit' Sep 29 at 5:47
6

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
    Sep 21 at 7:25
5

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

0
4

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
3

I solved the error. Just add the below code into Pod file

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

Note: Delete the Pod folder first, then go to the ios directory and try to run pod install after refactoring the pod file using the above code provided.

3

With Flutter version 3.13.5 the issues with Xcode 15 seems to be fixed. What I did was upgrade Flutter, remove macOS folder (I believe same holds for iOS) and recreate platform project:

flutter upgrade
rm -r macOS
flutter clean
flutter create .
flutter pub get
1

open /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.0.sdk/System/Library/Frameworks/WebKit.framework/Headers/WKWebsiteDataStore.h, change __IPHONE_OS_VERSION_MAX_ALLOWED to 180000

1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Stanly
    Oct 6 at 6:01
0

I working this with Flutter Cocoapods v1.13.0

brew command

brew upgrade cocoapods

without brew

sudo gem upgrade cocoapods
0

Use the latest version of flutter_inappwebview. ie. flutter_inappwebview: ^5.8.0. They have fixed the issue in the latest version

0

I fixed all my Xcode 15 issues with flutter by going into [System Settings -> General -> Storage -> Developer -> & Delete the XCode Cache]

0

If you're using Flutter, Firebase, XCode 15...

I struggled with this problem for a long time. This is what fixed it for me.

  1. In XCode, navigate to your Podfile and on the chunk of code (should be at the bottom of the file) that starts with post_install ... you want to change/replace it to this:
post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end
  1. Add your Firebase GoogleService-Info file to XCode. This must be done through XCode — not the file system — else it won't work. Official instructions found here. My instructions: Open XCode and right-click on the Runner in the top left then click Add Files to "Runner"... and upload your GoogleService-Info.

  2. Update any firebase_SOMETHING dependencies from your pubspec.yaml to their newest versions. For example, I had firebase_analytics in my pubspec.yaml that looked like this: firebase_analytics: ^10.4.4 and I changed it to firebase_analytics: ^10.5.1. You can check the newest versions of a package on pub.

  3. From your project directory (the one containing lib, ios, etc.) you want to run: cd ios ; pod repo update ; rm Podfile.lock ; pod install --repo-update ; cd .. ; flutter clean ; flutter pub get ; flutter run.

After this, my app ran for the first time in days :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.