I have an Xcode project which was downloaded from the internet so I don\'t know which Xcode version was used to write it but the language is Swift 2. I opened it in Xcode 7.
I had the same problem recently with Xcode 11.4 on Catalina 10.15.4.
Rebooting, cleaning project folders, or deleting the derived data directory did not help. What solved the problem for me was to remove and reinstall Xcode (I use the AppStore version).
It is possible, that I caused the problem myself by reinstalling macOS 10.15.4 via a Combo-Update.