I ran into the same problem and reinstalled Xcode, the problem is still there.
Finally, I found that my Xcode SourceKitService logs failed and found an answer on Twitter
open a terminal and execute:
rm -rf ~/Library/Developer/Xcode/DerivedData
It works for me!
or you can reset to set the default Xcode on the command line
defaults delete com.apple.dt.Xcode
source share