I have this problem before for accidentally revoked my certificate. Then all my swift projects have this problem. There are two ways to solve this:
Click on Product → Clean (or CMD + Shift + K)
Or by manually cleaning the Xcode setting files:
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"
rm -rf ~/Library/Developer/Xcode/DerivedData
rm -rf ~/Library/Caches/com.apple.dt.Xcode
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…