CodeSign error: Certificate identity \'iPhone Developer: XXXX (12345678)\' appears more than once in the keychain. The codesign tool requires there only be one.
So I
I just spent a fair amount of time struggling with this same issue. After all the attempts to fix it, I finally came to realize that it's a bug in Xcode. This post gave me a clue to fix it: certificates magically re appearing in your keychain
In my case, the matching private key was in the System keychain, and just had my name on it (hard to tell it was for provisioning). I had to:
An interesting observation is that when you delete the certificate, it doesn't delete the associated private key. Visually, it shows the private key below the cert. Don't be fooled.
Good luck!