I am getting this error:
CodeSign error: Certificate identity \'iPhone Developer: XXX\' appears more than once in the keychain. The codesign too
I spent for this a half-day and finally found the solution
Then close Keychain.app and go to Xcode -> Organizer
Build again your app:)
I've tried everything suggested here but nothing worked for me except reinstaling XCode 4.3 magically solved the case.
Figured out a really easy way to fix this in 4.6.1. You can do it without restarting anything or deleting any profiles!
With Keychain Access and your Xcode project open:
Hope it helps!
Xcode 4 has a new feature "Automatic Device Provisioning". It's located in the organizer under library/provisioning profiles. If you have this enabled it will automatically download your provisioning profiles from the apple developer provisioning server and thus you get the error of having duplicates. The easiest way to fix it is to delete all provisioning profiles and press refresh for the "Automatic Device Provisioning". This will load your provisioning profiles from the server and will fix your problem.
The solution was to go into organizer - under library - provisioning profiles, delete all of them and then reinstall any profiles I still needed.
I had this same problem and the solutions above did not solve my problem (well nearly).
I had the same duplicate developer ID/certificate that everyone is complaining about, and I tried deleting all my profiles, revoking/reissuing my cert, making sure there were none in the system keychain, restarting, etc etc.
In the end it turned out there was a certificate in the system keychain, one that had expired and so was hidden by default in the list.
Make sure you can see expired certificates in KeyChain
To do this: