In my case Xcode was not accessing certificates from the keychain, I followed these steps:
- delete certificates from the keychain.
- restart the mac.
- generate new certificates.
- install new certificates.
- clean build folder.
- build project.
- again clean build folder.
- archive now.
It works That's it.