I am getting this error:
CodeSign error: Certificate identity \'iPhone Developer: XXX\' appears more than once in the keychain. The codesign too
For posterity, here's the strategy to get around this problem in our automated build script:
Just installed Xcode 4.6.1 and started having this problem again. The last time was a long time back. I deleted the old provisioning profiles and the certificates, but still could not build.
This time it turns out that I had 2 certificates listed for me in the team account of the developer portal. The first was expired, the second was not. Xcode kept grabbing the first one it found while refreshing (or maybe both).
I deleted both certificates from the keychain, then manually downloaded the good one from Apple's portal and manually added it to the keychain. Now I can build again.
(And I sent a request to the team admin to remove the old certificate.)
For what it's worth, @AndreasPrang, your answer worked when all of the above didn't. I could see the expired certificate was not anywhere in the keychain, yet when I did a build, Xcode said it was. Deleting the provisioning profiles (all of them), selecting my name in the Team section and clicking the refresh icon in the lower right of the organizer also did not help. Restarting Xcode didn't help, but shutting down XCode, deleting ~/Library/Developer/Xcode did. When I restarted XCode, it rebuilt everything and was happy.
the above method not work for my case
finally , i go to keychain
and search the key by entering the name
i finally found the cert which is supposed to be deleted before . then i deleted it and the problem solved
it's really frustrating , and i don't know whether it's the bug ....... really exhausting.