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 had this problem and read every piece of information about it, finally I've found the solution on my own. What people failed to mention is that BEFORE cleaning the certificates in Xcode organizer and BEFORE cleaning the expired keys in your keychain you need to make sure that you don't have any expired certificates in the Provisioning Portal. If you'll have even one expired certificate for an old app that used the old Developer certificate Xcode will pull that into its organizer with first build and from there it will go to your keychain and will cause a duplicate.
In my case deleting the certificates didnt work. XCode 4 seems to cache or restore them. The trick that finally worked for me was to have keychain and xcode running. Then in keychain drag my 2 certificates (dev+dist) from 'login' to 'system'. Then the duplicates magically reappeared and i was able to delete them, and then i dragged the certificates back to 'login'
I think I figured out why the simple delete is not working. Because the dev certificate is still stored in the provision profile, when I close/re-open the Xcode after deleting the certificate in Keychain, I saw the old certificate come back. So I delete it again. It worked.
The simple delete the profile solution did not work for me.
It's very easy, export the correct Certificate to your desktop. Delete that Certificate in the keychain. Try to build source with error message (have no cert..) Then import again the certificate. => Success!
I was dealing with same problem once. And I have solved it by removing unused provisioning profile from Organizer tab in xcode. Actually Keychain will get that certificate from this provisioning profile which is either expired certificate or the build by revoked certificate.
So you just have to delete this provisioning profile from Organizer tab. Organizer is on right-top side button of xcode Open it and than in Organizer remove the provisioning profiles that you don't using.
Here is the screenshot,
And don't forget to remove extra certificate from the keychain but after that those certificate does not appear again.
I have the same issue with xcode45-DP1. this works for me:
remove all certificates related to your account from keychain. QUIT keychain
remove all provisioning profiles related to your account from xcode:organizer:device:Library:provisioning profiles. QUIT xcode
revoke your certificate and regenerate it and download it to your build machine
before download provisioning profile, click on Edit next to the download button to make sure your name is selected.
Then download the provisioning profile
double click on the certificate to install it onto keychain
drag the provisioning profile to xcode:organizer:device:Library:provisioning profiles
do not click the refresh button from the xcode.
make the build.