The following steps solved the problem for me. I was having the issue where it was not compiling for the device or archiving, working fine for simulator.
- Open keychain access.
- Lock the ‘login’ keychain.
- Unlock it.
Clean and build after doing the above steps and everything works fine now.