Same issue here. It starts months ago, when I have Big Sur and Xcode 12. Then I've update Xcode and nothing changes, so I also updated to Monterey and the issue is still there. For days I can't build anything, then without any changes it works again.
Now I've Xcode 13.2.1 and MacOs 12.2.1. It's frustrating work in this conditions.