得益於這個文章:http://www.cocoachina.com/bbs/read.php?tid=96925
感謝樓主neutyz&cocoachina
癥狀
Certificate identity 'iPhone Developer: xxxx ho (2J123456HA)' appears more than once in the keychain. The codesign tool requires there only be one.
解決辦法
原因是keychain access中存在到期的'iPhone Distribution: xxxx',但沒有顯示在鑰匙鏈/登入中,而是在鑰匙鏈/系統中,並且是隱藏的,因此需要在鑰匙鏈->顯示->顯示到期認證,然後把鑰匙鏈下的登入和系統的到期認證都刪掉。
而且我在搜尋答案的時候,看到一篇文章,有可能刪除到期認證失敗,但是在keychain裡面卻顯示刪除成功,這個問題的解決方案是重啟keychain,刪除,重複這個過程直到真正刪除成功。
有時候在keychain裡面找不到已到期、多餘的認證,但我們在xcode的target的building setting的code signing裡面卻能夠看到多餘的認證,這個就證明我們的keychain並沒有清楚乾淨。
總結,解決這個問題的步驟是:1.清掉keychain裡面多餘的認證。2.重新整理xcode裡面的provisioning profile。
下面貼出官方的Troubleshooting:
This error indicates that while searching all keychains, Xcode found more than one signing certificate for the same iOS developer program team member, and it does not know which one to use for code signing.
To resolve the problem, use the following process to ensure that there is only one copy of each certificate type: "iPhone Developer" or "iPhone Distribution" within the entire keychain, for the same team member.
In Keychain Access, make sure your "View" menu > Show Expired Certificates option is turned ON
Click the "Certificates" 'Category' and then click through every one of the keychains you have listed in your 'Keychain' sidebar in Keychain Access. If you see any duplicates, even expired certificates, delete those duplicates.
Click the "Keys" 'Category' in Keychain Access.
Navigate through every keychain looking for and deleting any "Orphaned Keys" that have the same Common Name as the affected certificate. Orphaned keys are ones that are not bound by a Disclosure Triangle to an iPhone Developer or iPhone Distribution certificate
that currently exists in the keychain.
If you found and removed any extra keys or certificates, please reattempt your build.
If the issue persists after removing all active or expired duplicate certificates or keys by the same common name, you might try removing *all* existing signing certificates and keys and replace them with new ones using the steps in How do I delete/revoke my
certificates and start over fresh?.
Finally, if the error persists even after creating new certificates, please control-click on the affected certificate in Keychain Access, choose "New Identity Preference" and click the 'Certificate' field. If you see duplicate certificates listed in here, this
is an known and uncommon issue with Keychain Access. To work around the problem, try the following:
Export your developer profile using the process in Transferring Your Identities.
Create a new OS X User Account, install Xcode for the new user and import the developer profile created in the previous step.