I don't know whether it's the best solution, but
It worked for me:
https://medium.com/@sergey-pekar/how-to-fix-annoying-xcode-26-not-building-swiftui-previews-error-cannot-execute-tool-metal-due-49564e20357c
Topic:
Developer Tools & Services
SubTopic:
Xcode
Tags: