There are a lot of potential causes of this problem. Make sure you have the certificate with its private key and the provisioning profile, and that they’re set in Xcode. But if you’ve tried everything else, then make sure you’ve done:
Build -> Clean All Targets
That fixed it for me.