I was getting this on command line builds using xcodebuild. Specifying a different DerivedData folder fixed it.
Chirag's thread on Stack Overflow mentions this solution: https://stackoverflow.com/questions/79118572/xcode-16-and-ios-18-project-not-compiling
Topic:
Developer Tools & Services
SubTopic:
Xcode