Fix Xcode 15 DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead

In Xcode 15 Apple changed the variable which points to the default toolchain location to $TOOLCHAIN_DIR from $DT_TOOLCHAIN_DIR. If some project/target used $DT_TOOLCHAIN_DIR then it need to be replace by $TOOLCHAIN_DIR.

1. Find DT_TOOLCHAIN_DIR Reference

To find out where in your project you are using this, you can search for DT_TOOLCHAIN_DIR in your project to find out where in your project you are using DT_TOOLCHAIN_DIR.

2. Fix for CocoaPods

If you are seeing only CocoaPods (pod) project is using $DT_TOOLCHAIN_DIR then you can add the following script in your Podfile to automatically update $DT_TOOLCHAIN_DIR to $TOOLCHAIN_DIR. This will only execute on Xcode 15 or later. It will not impact other developers who is using Xcode 14.

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

3. Fix for your project

If you see some references of DT_TOOLCHAIN_DIR in your main project/taget, then you need to update that manually.


Discussion

Read Community Guidelines
You've successfully subscribed to Developer Insider
Great! Next, complete checkout for full access to Developer Insider
Welcome back! You've successfully signed in
Success! Your account is fully activated, you now have access to all content.