XCode 15 & CocoaPods

Apparently XCode 15 broke Realm projects which use CocoaPods, along with Flutter and a myriad of other libraries.

The CocoaPods folks are working on fixing CocoaPods (release is coming very soon) but in the meantime if your Realm project does not build and throws errors like

DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead

There are a couple of proposed temporary fixes. One is to add a post_install to your podfile, which didn’t work for me.

However, this little section of code worked - project builds and runs normally.

In Terminal, cd to your project folder and paste 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

Credit to the StackOverflow post Issues while building iOS project with flutter - Stack Overflow and scroll down to the answer from Mecki

Heres the git Xcode 15 Beta 5 fix: Fix build failed due to `DT_TOOLCHAIN_DIR` by marcuswu0814 · Pull Request #12009 · CocoaPods/CocoaPods · GitHub

Which has info but none of the fixes worked for us. Looks like a new CocoaPods will be out in a couple of days.