Xcode 4 -reinstalls keychain certs that I delete

XcodeXcode4Code Signing

Xcode Problem Overview


I am getting this error:

> CodeSign error: Certificate identity > 'iPhone Developer: XXX' appears more > than once in the keychain. The > codesign tool requires there only be > one.

At first I though, no worries, I will just go into keychain and delete the duplicate (older) one, which I did. I went back, closed Xcode, reopened Xcode and project, same error. wtf I though to myself. Back into keychain and the cert is there again. I delete both certs, repeat, and notice as the project loads, the two certs I deleted pop back into the keychain.

After much searching, I ensured I did not have the cert in the system keychain, which I did not. Also did a clean and rebuild. When I had duplicates with Xcode 3 I could just clean up the keychain duplicate and I was good. But with Xcode 4 it literally just reinstalls them somehow when I open the project. I even deleted all .cer files on my system that it might possibly be pulling them from.

Any suggestions?

Xcode Solutions


Solution 1 - Xcode

The solution was to go into organizer - under library - provisioning profiles, delete all of them and then reinstall any profiles I still needed.

Solution 2 - Xcode

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:

  1. Open Keychain Access
  2. Click View menu
  3. Click Show Expired Certificates
  4. then look for, and delete expired developer certs

Solution 3 - Xcode

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.

Solution 4 - Xcode

if you want to mess with keychain access to remove the expired certificate, you may try this:

  • create a new keychain, name it "expired" and move ONLY the expired certificate to it.
  • delete the newly created "expired" keychain which contains ONLY the expired certificate, when asked select "Delete references & files".

the expired certificate disappears together with the keychain. worked perfectly for me.

Solution 5 - Xcode

  1. Remove all Provisioning Profiles from XCode Organizer;
  2. Remove old Developer Certificates from Keychain Access;
  3. Generate Provisioning Profiles with the correct Developer Certificate only;
  4. Download and install the new Provisioning Profiles;

-- EDIT --

Merge @Codezy's answer and @iphone007's comment.

Solution 6 - Xcode

Deleting provisioning profiles in Organizer's library, additionally, you should delete iPhone developer certificate in Keychain Access. (The certificate's name is probably like "iPhone Developer: XXXXX ..." and indicated by red X sign, as expired)

Solution 7 - Xcode

I spent for this a half-day and finally found the solution

  1. Open KeyChain Access.app
  2. Select "System" in "Keychains" menu on the left part of Keychain application screen
  3. Select "Certificates" in "Category" down menu
  4. Remove all old certifications.

Then close Keychain.app and go to Xcode -> Organizer

  1. Remove all Provisioning Profiles in Library menu
  2. Remove all Provisioning Profiles in Devices menu
  3. Push "Refresh" button in Library menu -> Provisioning Profile
  4. Add needful profiles to your device

Build again your app:)

Solution 8 - Xcode

For posterity, here's the strategy to get around this problem in our automated build script:

  1. Before building, move the ~/Library/MobileDevices/Provisioning Profiles directory aside
  2. Check to see if the iPhone Configuration Utility is running and close it (certs always reappear if this app is open. In XCode 4.1 you need to close the organizer too.)
  3. Run you build
  4. Move the Provisioning Profiles directory back
  5. Profit?

Solution 9 - Xcode

I've tried everything suggested here but nothing worked for me except reinstaling XCode 4.3 magically solved the case.

Solution 10 - Xcode

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:

  1. In Xcode, open Organizer - "Devices" and select the "team" with the duplicate certificate.
  2. Switch to Keychain Access and delete the old duplicate certificate(s). Note: Make sure you turn on "show expired certificates" to not miss any.
  3. The certificates will have disappeared from the "team" profile in the Xcode Organizer.
  4. Clean project and build.

Hope it helps!

Solution 11 - Xcode

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.

Solution 12 - Xcode

Quoting an answer to a duplicate of this question, some of Xcode's bugs in this area can only be solved by restarting OS X.

In the end, I achieved success by deleting everything mentioned in any of the answers to this question, restarting, then manually installing the parts I needed (I did not trust/try the automatic profile/certificate download feature).

Solution 13 - Xcode

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.

Solution 14 - Xcode

The other reason that xcode keeps installing your certificate is because you did not delete key, only certificate. You need to delete private key (and corresponding public key) as well as certificate in keychain otherwise xcode will reinstall the certificate.

Check here To remove development and distribution certificates from your keychain

Solution 15 - Xcode

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.)

Solution 16 - Xcode

  1. Remove ~/Library/Developer/Xcode
  2. Clean Project

build...

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionCodezyView Question on Stackoverflow
Solution 1 - XcodeCodezyView Answer on Stackoverflow
Solution 2 - XcodeJaguView Answer on Stackoverflow
Solution 3 - XcodeCyprianView Answer on Stackoverflow
Solution 4 - XcodefelisView Answer on Stackoverflow
Solution 5 - XcodeMr. MíngView Answer on Stackoverflow
Solution 6 - XcodeKenialView Answer on Stackoverflow
Solution 7 - XcodeStanView Answer on Stackoverflow
Solution 8 - XcodeBryanView Answer on Stackoverflow
Solution 9 - Xcodenh7aView Answer on Stackoverflow
Solution 10 - XcodeJohn CaplingerView Answer on Stackoverflow
Solution 11 - Xcodechings228View Answer on Stackoverflow
Solution 12 - XcodeAbhi BeckertView Answer on Stackoverflow
Solution 13 - XcodefporcaroView Answer on Stackoverflow
Solution 14 - XcodeQiulangView Answer on Stackoverflow
Solution 15 - XcodeWalt SellersView Answer on Stackoverflow
Solution 16 - XcodeAndreas PrangView Answer on Stackoverflow