The problem was solved by first cleaning the build folder (Product -> Clean build folder or Command + Shift + Option + K) and then deleteing derived data (~/Library/Developer/Xcode/DerivedData/ModuleCache).
Topic:
Code Signing
SubTopic:
Certificates, Identifiers & Profiles
Tags: