Xcode Provisioning Profile Expiring - xcode

I'm trying to clear a couple non-fatal errors from a couple projects. They are both "Target Integrity" "Provisioning profile is expiring: . . . ".
Yet, I don't have the Provisioning profile that's expiring as a part of the project in any way. Can anyone tell me why it might be giving me an error like this for a Provisioning profile that is being used only by a different project?

Had the same problem. This is how to fix it:
Open Xcode > Preferences > Accounts
Click 'View Details' on the relevant account, and you'll see all associated provisioning profiles will open in a list. Sort the list by expiration date to find expired profiles, and for each one right click and choose 'show in finder'. Then you can simply delete it.
When you delete an expired profile in the finder it immediately disappears from Xcode and from the warnings panel.

You can find your provisioning profiles in
~/Library/MobileDevice/Provisioning Profiles/
There you can see all your provisioning profiles, but it's difficult to know which one is which because they are named with a UUID.
However, you can install this QuickLook plugin to see details about each profile and delete the ones that are expired:
https://github.com/chockenberry/Provisioning
The warning disappears instantly from Xcode after you delete the profile.
EDIT:
An easier method to clean up old profiles may be to download iPhone Configuration Utility from here:
http://support.apple.com/downloads/#iphone%20configuration%20utility
It gives you a nice overview over you installed profiles and they can be deleted as well.

Xcode -> Preferences -> Accounts -> View Details
Then select that particular provisioning profile and click refresh button.
If you are still having warning then go to
https://developer.apple.com and
select provisioning profile and click edit and then done. After that do the refresh procedure described before in X-Code

sigh manage -e to delete all expired profiles
sigh repair will renew all profiles (requires login)
https://github.com/fastlane/sigh

One liner here. No need to download plugins, utilities and all that crap.
ls | grep -l 'com.companyname.AppName' ~/Library/MobileDevice/Provisioning Profiles/*.mobileprovision | xargs rm

In the end, I simply went into my Developer's account and renewed the expiring provisioning profile, even though I don't need/use it any more. Error is gone.

Related

Delete provisioning profile from Xcode 5

I've struggling with this for hours. I have 2 same provisioning profiles I've created and the new profile didn't substitute the old one (which expires 6 days earlier than the new one). Through the XCode 5 menu I can't seem to delete the duplicate provisioning profile. Any workaround in this situation?
If you delete the profile from the Apple development a/c and hit refresh in XCode (Using xcode>Preferences>Accounts) then these profiles will be gone.
You can remove them from the this directory on your machine:
"~/Library/MobileDevice/Provisioning\ Profiles"
In the Xcode Preferences, go to Accounts, then go to your apple ID, then click "View Details"
Click the provisioning profile which you would like to delete, then press the "delete" key ONCE. Then click the refresh icon for manually update the list(pretty counterintuitive...).
Using this method I was able to delete all but one copy of the same provisioning profile, after which the delete does nothing.
You probably don't need to delete the duplicate profiles. Just go to
Xcode / Preferences / Accounts / / View Details
and hit the refresh button.
I did this and my duplicate provisioning profiles disappeared. Now when I post builds to TestFlight the distribution lists are all correct.
In the Xcode Preferences--> Accounts, delete your account, add account again,click on your developer ID, press refresh, select provisioning profile again under build settings.
THATS IT. ALL YOUR PROBLEMS ARE SOLVED
I am using "iPhone configuration utility for Mac OS x" provided by apple for managing my all provisioning profiles for Xcode 5.
From apple's website:
iPhone Configuration Utility lets you easily create, maintain, encrypt, and install configuration profiles, track and install provisioning profiles and authorized applications, and capture device information including console logs.
You can download it from here
You can delete the provisioning profile:
Open the utility and select the provisioning profile from the list.
From the top menu select "Edit" than "Delete"
To remove any reference to an unwanted provisioning profile from XCODE 5 here is what I did:
1) Browse into the YOURAPP.xcodeproj directory
2) With vi I opened up the project.pbxproj file
3) Find PROVISIONING_PROFILE="ID_OF_THE_PROV_PROFILE_YOU_WANT_TO_DELETE"
In every instance I saw this in the file I just set it to "" and XCODE never gave me an error again.
All of the methods mentioned so far will still fail to delete certain "Managed by Xcode" profiles, which you may find will continually re-appear no matter what you do to delete them.
The problem seems to be that certain profiles are auto-generated by Xcode/Apple Developer Centre based on the App Ids you have. In my case I see one "Developer" profile per app ID (including the wildcard).
I would imagine that the only way to get rid of these is to remove the App Id itself through the Dev Centre. Often this is not possible since the Dev Centre will complain that the app "...exists in the App Store so it cannot be removed" - even when the app in question is not actually in the store.
None of the previous suggestions worked for me. What did finally eliminate the unwanted profiles was the following:
Remove the developer account from Xcode > Accounts
Quit Xcode.
Delete the unwanted provisioning profiles in the developer portal.
Delete all the files ~/Library/Developer/Xcode/DeveloperPortal*.*
Empty the trash.
Restart Xcode and add the developer account back in.
I was thrashing around so this might not be quite the magic formula but something along those lines. By design, Xcode automatically creates provisioning profiles based on the app identifiers set up in the developer portal with names like "Mac Team Provisioning Profile: ". This is a great feature but it adds to the confusion with this deletion issue.
From my experimentation i believe that Xcode pulls the provisioning profiles straight from the dev center.
i say this because i created a new provisioning profile from the dev center and it appeared in Settings > Accounts before i double-clicked the .mobileprovision file.
So basically, delete the profiles from developer.apple.com
In my case this worked:
Right click on a provisioning profile in the accounts tab -> view details panel.
Click the option show in finder -> delete them directly in finder.
For all the people who are seeing the profiles magically reappear after deleting them and hitting refresh, simply wait a few minutes after deleting and before hitting the refresh button.
For deleting provisioning profile we can use iPhone Configuration Utility software.
iPhone Configuration Utility Software -> Install this software -> Open Software -> Provisioning Profiles -> find list of your all profile -> Press Backspace button, it will ask to delete provisioning profile ->Click on delete provisioning profile button. So it will remove it from your existing Xcode application and even from your PC.
I've figured out that it takes some time interval to sync between local path of the provisioning(~/Library/Developer/Xcode/DeveloperPortal) and the iTunesConnect server. So once you have deleted your provisioning profile on the local path and on the iTunesConnect server (you should remove both for clearing), you need to wait at least 5 minutes, otherwise you will see the files you've deleted again on the local path when you try to press 'fix it' button in Xcode.

Xcode5 "No matching provisioning profiles found issue" (but good at xcode4)

Everything is OK on Xcode4.6. When I try to use Xcode5 dp6 to run app on devices. I got an error of "No matching provisioning profiles found issue". How can I resolve this issue?
Don't forget to change profile in Provision Profile sections:
Ideally you should see Automatic in Code Signing Identity after you choose provision profile you need. If you don't see any option that's mean you don't have private key for current provision profile.
What really confused me was that there are two different sets of build settings:
1) for the Project
2) for the Target
In the sidebar (top left) there is a blue icon that represents your project. Click that:
Then in the main panel to the right, in the top bar, just to the left of the word, "General," there is a small icon of your Project. Click that, and now select the Target in the pop-up menu that appears:
Once you've selected the Target, now the build settings for the target can be changed. They are different than the ones for the Project itself... weird! I'm not sure why there are build settings for the Project as a whole, that are different from the Target, since the Target's settings are what gets used during building. So why even have settings for the Project? Not sure.
But that's how you change them. This solved the issue for me: go into the Target (not the Project!) under Code Signing > Provisioning Profile > and change the settings to the proper profile. For a long time I was just changing them in the Project only, since I didn't know I was supposed to select the Target, and I kept having this issue. This fixes it!
Setting your provisioning profile moved. It confounded me for a while until I found it also.
Select your project file (to open target)
Click on the "Build Settings" tab
Scroll down to "Code Signing" and see the new "Provisioning Profile" section there.
OK - all answers provided above are correct to some extend, but did not resolve this issue for me. I'm using Xcode5.
There are lots of threads around this general error but from what I read this is a bug in Xcode dating back to 3.x versions that can randomly create conflicts with your Keychain.
I was able to resolve this by doing the following:
Open Xcode -> preferences -> Accounts: delete your developer account
Open Keychain: Select Keys, delete all iOS keys; Select My Certificates, delete all iPhone certificates
Navigate to '/Users//Library/MobileDevice/Provisioning Profiles', delete all files (this is where Xcode stores mobile profiles)
Open Xcode -> preferences -> Accounts: re-add your developer account
Navigate to Project properties, Target, General Tab and you should see the following
Click 'Revoke and Request' (I tried this, it may take a few min) or 'Import Developer Profile' (or download from Apple developer portal and import this way, should be faster..)
FINALLY: you can go over to Build Settings and set 'Provisioning Profile' and 'Signing Settings' as described by everyone here..
Doing this and only this resolved this error for me.
Here's a simpler solution that worked for me:
In XCode5, double-click on your app's target. This brings up the Info pane for the target. In the "Build Settings" section, check the "code signing" section for any old profiles and replace with the correct one. update the value of "code signing identity" and "provisioning profile"
Sometimes, especially after generating a new certificate or starting to use a new code signing identity, there seems to be no other way to fix this, other than doing some cleaning the .pbxproj file. This is probably a bug that will be fixed, so if you are reading this long after this post, maybe you should try some other solution.
There is an excellent post about this in the pixeldock blog:
http://www.pixeldock.com/blog/code-sign-error-provisioning-profile-cant-be-found/
In short, mostly quoting from that article, you need to:
Make sure you have fetched all your remote iTunes Connect certificates in xcode5 from Preferences, Accounts, (select your account), View Details, press refresh button. (Normally, I answer no when xcode asks if I want to create certficate signing requests, it's not necessary when you only want to download/refresh your certificates)
Close Xcode
Right click on your project’s .xcodeproj bundle to show it’s contents.
Open the .pbxproj file in a text editor of your choice (make a backup copy first if you feel paranoid)
Find all lines in that file that include the word PROVISIONING_PROFILE and delete them.
Open Xcode
Enter your target and select the provisioning profile that you want to use.
Build your project
Good luck!
In xcode5 from Preferences, Accounts, (select your account), View Details, press refresh button. then select Provision Profile in build settings.
In my case the "Fix Issue" button triggers a spinner for about 20 seconds and fixes nothing.
This works for me (iOS 7 iPhone 5, Xcode 5):
Xcode > Window > Organizer > Devices
Find the connected device(with a green dot) on the left pane.
Select "Provisioning Profiles"
On the right pane, there is a line with warning.
Delete this line.
Now go back to click the "Fix Issue" button and everything is fine - the app runs in the device as expected.
I have 2 targets in my project, Free and Paid.
My mistake was i was looking at my free target while trying to build the paid target, a stupid mistake but possible someone out there might learn from this as well.
I get the same question as you you can click here :
About the question in xcode5 "no matching provisioning profiles found"
(About xcode5 的no matching provisioning profiles found )
When I was fitting with iOS7,I get the warning like this:no matching provisioning profiles found.
the reason may be that your project is in other group.
Do like this:find the file named *.xcodeproj in your protect,show the content of it.
You will see three files:
project.pbxproj
project.xcworkspace
xcuserdata
open the first, search the uuid and delete the row.
All of drop down lists disappeared in Build Settings after running the Fix Issue in Xcode 5. Spent several days trying to figure out what was wrong with my provisioning profiles and code signing. Found a link Xcode 4 missing drop down lists in Build Settings and sure enough I needed to re-enabled "Show Values" under the Editor menu. Hopefully this helps anyone else in this predicament.
Also, I had to clear my derived data, clean the solution and quit and reopen Xcode into for the code signing identities to correctly appear. My distribution provisioning profiles where showing up as signed by my developer certificate which was incorrect.
I had the same error today, with XCode 6.1
What I found was that, no matter what I tried, I couldn't get XCode to stop complaining about this Provisioning Profile with a GUID as its name.
The solution was to search for this GUID in the .pbxproj file, which lives within the XCode .xcodeproj folder.
Just find the line containing your GUID:
PROVISIONING_PROFILE = "A9234343-.....34"
and change it to:
PROVISIONING_PROFILE = ""
One other thing to check: Your XCode PROJECT settings contain your Provisioning Profile & Code Signing settings, but, there is a second set under your project's "TARGETS" tab.
So, if XCode is complaining about a Provisioning Profile which isn't the one quoted in your project settings, then go have have a look at the settings shown under "TARGETS" in your XCode project.
(I wish someone had given me this advice, 4 painful hours ago..)

A valid provisioning profile for this executable was not found... (again)

I know this has been asked and answered multiple times but I'm tearing my hair out as none of the proposed solutions appears to work.
I receive the above error, despite having a valid provisioning profile which, as far as I can tell matches the bundle identifier:
I've followed the steps in various suggested solutions on this site, including deleting all existing certificates and starting again, as suggested here and here.
One thing I have noticed is that the profile doesn't show up in the code signing lists, either for target or project.
Can anyone offer any further suggestions?
This happened to me yesterday. What happened was that when I added the device Xcode included it in the wrong profile by default. This is easier to fix now that Apple has updated the provisioning portal:
Log in to developer.apple.com/ios and click Certificates, Identifiers & Profiles
Click devices and make sure that the device in question is listed
Click provisioning profiles > All and select the one you want to use
Click the edit button
You will see another devices list which also has a label which will probably say "3 of 4 devices selected" or something of that nature.
Check the select all box or scroll through the list and check the device. If your device was unchecked, this is your problem.
Click "Generate"
DON'T hit Download & Install – while this will work it's likely to screw up your project file if you've already installed the provisioning profile (see this question for more info).
Open Xcode, open the Organizer, switch to the Devices tab, and hit the Refresh button in the lower right corner. This will pull in the changes to the provisioning profile.
Now it should work.
If none of above stated works then check for your device date, make sure your device date doesn't exceed profile expiry date i.e. not set to far future.
+1 to banging my head against the wall for a day or two...
Also check this setting:
Build Settings -> Code Signing -> Provisioning Profile
After following the above steps, "Automatic" setting worked for me. ~kjm~
File > Workspace Settings > Set Build system to "Legacy Build System"
Xcode5 has broken this again (congratulations to Apple for failing to bother testing one of their buggiest bits of code. Again).
A new way to break/fix it:
If you have:
An old profile on your device (team profile, or non-team profile)
A new profile generated automatically on the App Store, by any copy of Xcode5, even if it's simply an update to the profile you already had
(NB: if any colleague adds themself to the profile, this triggers the above "change")
You use the new "Accounts" dialog to download profiles (NB: this is now REQUIRED by Apple for various situations - all other approaches, including manual download, appear to be unsupported. Even though the Apple Developer site TELLS YOU TO MANUALLY DOWNLOAD! Don't do it! It breaks Xcode5!)
Xcode5 will INCORRECTLY hide AND RENAME that profile in the drop-down selector in Build Settings
(I detest this drop-down. Some idiot at Apple keeps removing information from it, and someone else keeps adding it back, it flip-flops between Xcode point releases. WHY??!?!)
There is NO WAY you can select the correct profile - whatever you select, Xcode5 will use the wrong one
The solution is easy enough. The "Apple engineering are lazy" solution:
Go to Xcode5 -> Window -> Organizer -> Devices
Select your device
Select provisioning profiles
Delete everything relating to your current project and/or Team (even other projects, if necessary - they can all be downloaded later if still needed!)
Re-build.
You should get an error from Xcode5 that the profile doesn't exist. Even though you manually had seleted the profile that was ALREADY PRESENT on your machine (yep - that dropdown is buggy again. It lies about the profile it selects behind the scenes!)
In the profile selector, select the "real" profile
Build, run - success!
It happened to me when I accidentally left the build in release mode.
This can happen if your provisioning profile has expired. Another reason could be that you device date exceeds the expiry date of your provisioning profile. Please make sure that your device date is correct.
After spending the day I realized it was a simple change in Project Settings
File -> Project Settings... -> Build System -> Legacy Build System.
In a project setting, you will see Build System named drop down and in that drop down select Legacy Build System
Delete all certificates from the keychain of the account which you are trying to use provisioning profile
Delete Derived data
Clean the folder(cmd+sht+alt+k)
Clean the project(cmd+sht+k)
Build & Run
In my case it was just after a new Program Licence Agreement was released so we had to accept them and it was fine.
I had this error because I was testing my app to perform a certain action in the future. In other words, I had a different time on my test device, therefore, the certificate would not allow me to build.
Apparently, my certificate expires in a few days...
In my case, it was the problem when I setup my time manually two month earlier on my iPhone. But when I changed to set time automatically, it worked fine.
Setting -> General -> Date & Time -> set time automatically
If it does not work then set time automatically of both mac & iPhone, it may work fine.
I have spent about a week solving this problem. Most of the answers are sort of magic (no logical purposes for these algorithms) and they were not useful for me. I found this error in Xcode console:
ERROR ITMS-90174: "Missing Provisioning Profile - iOS Apps must contain a provisioning profile in a file named embedded.mobileprovision."
And found this answer solving this issue. The case is to switch Xcode Build system to the Legacy one.
I was deploying my Ionic app.
After wasting my half day I got this working.
Select Target > Edit Scheme > Select Run > Change Build Configuration to debug
I'm still not sure what the issue was but deleting all certificates and starting over (albeit twice) eventually solved it.
My best guess is that I've missed some small but important detail of the procedure. Unfortunately I can't be any more specific than that.
Make sure you have added your device - https://developer.apple.com/account/ios/device/create
Go into iTunes and click on the serial number and it'll change to the UDID - then right click to Copy the UDID and register it as your device.
You can then add that device to your provisioning profile.

Xcode build warning - Target Integrity - Provisioning profile is expiring only for the ProjectnameTests Target

All my apps that i've created so far do this. It does nothing to the app or being able to run it but it's just annoying always having that 1 warning.
I'm Using
Xcode 4.2
OSX 10.7.3
This is the actual warning:
-Target Integrity
Provisioning profile is expiring
Here's an image of it just so I don't have to try and explain. (Edited it and put 'Project' where my actual project name was for privacy)
Thanks for any help!
I had the same issue.
Worked out in the end it was Xcode warning about some expired profiles generally - not ones specifically linked to the current project.
To fix I went to Organizer/ Devices Tab and under Library select Provisioning Profiles
I had two profiles in the list that had expired - I didn't need them so I just right clicked and deleted them.
Warning then went away.
This is a bit different with Xcode 5 now when working with Teams ...
I go the same warning of an expiring old profile which didn't exist anymore - but it still did exist in the local Account setting for the connected team in Xcode (Xcode -> Preferences -> Accounts -> <team account in question> -> View Details). So I just did a refresh on these profiles, and yes, the warning was gone.
Unfortunately there are many more expired profiles for other apps in this team account which I just synched into my local Account setting (and I can't just remove them, as it's a client's account ..) - and now Xcode complains about all of them being expired. Guess you should be happy with what you got sometimes, it can get worse ...
I got the same warning on my old project today.
I tried this, and the warning went away.
At 'Build Settings' -> 'Code Signing Identity', Choose 'Automatic Profile selector'.
For Xcode 6 you need to:
go to the Preferences (Cmd + ,)
Accounts
choose your account
choose your team
Click view details
Choose provisioning profile from warning
right click (show in Finder)
remove from Finder
Now the warning should disappear or you will need to repeat above steps for another warning
I deleted all the provisioning profile from
cd ~/Library/MobileDevice/Provisioning\ Profiles/
and it's gone.
You can use this shell script the get the names of the provisioning profiles
It is a warning that your provisioning profile is about to expire and you should renew it.
You can do this at Apple's developer center website. If your developer profile program is also about to expire, you should renew it too.
I had to also restart Xcode after deleting the old profiles to get the warnings to go away.
I have the similar problem, Xcode say one provisioning profile is expiring.
Then I go to the developer.apple.com to delete the expiring provisioning profile, it fixed.
Hope can help you.
I had this problem because a provisioning profile I used was signed with a certificate that was revoked/expired. First, go to the member center and delete expired and invalid provisioning profiles. Regenerate the ones you need. To clean up Xcode, go to Preferences-> Accounts, select your account.
Click view details.
Right click any profile -> Show in finder. Delete all of them. Then go back to XCode, close details and reopen (to refresh) and re-download the ones you need (there'll be a download button for each profile).
Warning gone. Xcode might complain about code signing issues, but clicking "Resolve" automatically clears this up.
Then everything worked.

Xcode 4 -reinstalls keychain certs that I delete

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?
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:
Open Keychain Access
Click View menu
Click Show Expired Certificates
then look for, and delete expired developer certs
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.
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.
Remove all Provisioning Profiles from XCode Organizer;
Remove old Developer Certificates from Keychain Access;
Generate Provisioning Profiles with the correct Developer Certificate only;
Download and install the new Provisioning Profiles;
-- EDIT --
Merge #Codezy's answer and #iphone007's comment.
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)
I spent for this a half-day and finally found the solution
Open KeyChain Access.app
Select "System" in "Keychains" menu on the left part of Keychain application screen
Select "Certificates" in "Category" down menu
Remove all old certifications.
Then close Keychain.app and go to Xcode -> Organizer
Remove all Provisioning Profiles in Library menu
Remove all Provisioning Profiles in Devices menu
Push "Refresh" button in Library menu -> Provisioning Profile
Add needful profiles to your device
Build again your app:)
For posterity, here's the strategy to get around this problem in our automated build script:
Before building, move the ~/Library/MobileDevices/Provisioning Profiles directory aside
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.)
Run you build
Move the Provisioning Profiles directory back
Profit?
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:
In Xcode, open Organizer - "Devices" and select the "team" with the
duplicate certificate.
Switch to Keychain Access and delete the old duplicate certificate(s). Note: Make sure you turn on "show expired certificates" to not miss any.
The certificates will have disappeared from the "team" profile in the Xcode Organizer.
Clean project and build.
Hope it helps!
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.
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).
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 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
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.)
Remove ~/Library/Developer/Xcode
Clean Project
build...

Resources