Reputation: 1631
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:
Firebase - DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead
FirebaseAnalytics - DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead
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.
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.
POD Update
Clean Build and rebuild
Upvotes: 150
Views: 100095
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:
sudo gem update cocoapods
pod install
Shift-Command-K
Upvotes: 1
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.
sudo gem uninstall cocoapods
brew uninstall cocoapods
/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
rbenv install 3.3.3 # or your preferred version
rbenv global 3.3.3
gem install cocoapods
Ensure that pod
is in your PATH:
rbenv rehash
pod --version
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
cd /path/to/your/flutter/project/ios
pod install
flutter clean flutter pub get cd ios pod install flutter run
Upvotes: 1
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
Reputation: 8047
For newbie IOS developer like me.
Go to Find
-> Find and Replace in workspace
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
Reputation: 1
Encounter similar issue some time ago. Maybe can try to delete ${inheritance}
in the Library search path in build settings.
Upvotes: 0
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
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
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
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:
First removed CocoaPods from the project. I followed How to remove CocoaPods from a project?
Cleared the DerievedData
and ran sudo gem update xcodeproj
then used pod install
.
Note: You can use pod cache clean --all
before pod install
Upvotes: 7
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
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
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
flutter clean
&& flutter pub get
rm Podfile.lock
&& rm -rf Pods/
pod install
&& pod update
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
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
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
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
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:
Go to the ios/
folder
cd ios
Update CocoaPods
sudo gem update cocoapods
If the above doesn't work, try installing it through Homebrew
brew install cocoapods
Make sure CocoaPods updated to 1.13.0 or newer version (if available)
pod --version
Delete the build cache
flutter clean
Delete the Podfile.lock file
rm Podfile.lock
Delete the Pods/ folder as well
rm -rf Pods/
Install the Flutter package dependencies
flutter pub get
Install the iOS pod dependencies
pod install
Update your local pods
pod update
Upvotes: 211
Reputation: 277
Go to pods → Firebase → Support files, both .release and .debug files.
Change "DT_TOOLCHAIN_DIR" into "TOOLCHAIN_DIR instead". It works for me.
Upvotes: 24
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
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
Reputation: 11
I followed these steps:
Upvotes: 2
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