Change your build setting for Code Signing Identity and Provisioning Profile first both in project and target...
Check image below ...
Change your Team from General tab...
i hope this will help you...
In some cases that error can be caused by "Generic iOS Device" being selected as active scheme.
Changing that to a specific device solved the problem for me.