When upgrading to Xcode 16.0, you may encounter the error:
DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead
This error occurs because DT_TOOLCHAIN_DIR is deprecated or no longer available in Xcode 16.0. Instead, you should use TOOLCHAIN_DIR. Here's how you can resolve this issue:
Steps to Fix the Error:
-
Open Your Project in Xcode 16.0
- Open your Xcode project that is showing the error.
-
Access the Build Settings
- In the Project Navigator, select your project file (the one with the blue icon).
- Select your target under the "Targets" section.
- Click on the Build Settings tab.
-
Search for LIBRARY_SEARCH_PATHS
- In the search bar at the top right of the Build Settings panel, type
LIBRARY_SEARCH_PATHS to filter the settings.
-
Locate References to $(DT_TOOLCHAIN_DIR)
- In the Library Search Paths section, look for any entries that include
$(DT_TOOLCHAIN_DIR).
-
Replace $(DT_TOOLCHAIN_DIR) with $(TOOLCHAIN_DIR)
-
Check Other Build Settings
- While you're in the Build Settings, it’s a good idea to search for
DT_TOOLCHAIN_DIR across all settings to ensure it's not used elsewhere.
- Replace any other instances with
TOOLCHAIN_DIR.
-
Update Dependencies (If Necessary)
- If you are using dependencies (e.g., via CocoaPods or Swift Package Manager), they might also reference
DT_TOOLCHAIN_DIR.
- For CocoaPods:
- Run
pod update to fetch the latest versions of your pods that may have updated build settings.
- If the issue persists, navigate to the Pods project and repeat the steps above for each affected pod.
- For Swift Packages:
- Update your package dependencies to ensure you're using the latest versions.
-
Clean and Build Your Project
- Go to Product > Clean Build Folder in Xcode.
- Then, build your project to see if the error has been resolved.
Why This Error Occurs:
- Deprecation of
DT_TOOLCHAIN_DIR: In newer versions of Xcode, certain build setting variables have been deprecated or removed. DT_TOOLCHAIN_DIR is one such variable.
- Use of Updated Variables: Xcode now uses
TOOLCHAIN_DIR instead, which you should use in your build settings.
Additional Tips:
- Automate the Replacement: If your project is large, consider using a text editor with find-and-replace functionality across files to replace
DT_TOOLCHAIN_DIR with TOOLCHAIN_DIR in your project files.
- Check for Custom Scripts: If you have custom build scripts or configurations, ensure they are not using the deprecated variable.
- Consult Documentation: Refer to the Xcode Build Setting Reference for more details on available build setting variables.
By updating your build settings to use TOOLCHAIN_DIR instead of DT_TOOLCHAIN_DIR, you should be able to resolve the error and successfully build your project in Xcode 16.0.