If you have a Developer ID account (you've paid Apple for the account) refer to this guide instead: Apple Guide- Maintaining Certificates
If you are a humble idiot who somehow lost the key for your Mac Developer account and your project won't compile and you see either of the following:
Choose your project in the Project Navigator and go to the General tab. In the Signing group, check the option 'Automatically manage signing'.
Even if it fails the first time, try again after restarting Xcode. It will arrange a new certificate for you.
I hope you found it useful. I would have saved so much time if I had found this info somewhere yesterday!