I found this solution which solved the problem mentioned in the first post for me:
The problem was solved by first cleaning the build folder (Product -> Clean build folder or Command + Shift + Option + K) and then deleting derived data (~/Library/Developer/Xcode/DerivedData/ModuleCache).
source