ChatGPT解决这个技术问题 Extra ChatGPT

Codesign error: Provisioning profile cannot be found after deleting expired profile

Tried to rebuild an app that was working just yesterday. Got a message that a profile had expired, so I removed it from the iPod and from iTunes. When I chose a new profile (one with an * in the identifier), I now get an error:

Code Sign Error: Provisioning Profile (long string) can't be found.

What am I missing? I looked through related questions and didn't see this scenario already.


s
shim

Sometimes your Xcode project file gets messed up, especially if you have an old project and first created it with an older version of Xcode/iPhone SDK.

What you need to do is open up the project file in a text editor, search for the 'long string' from your error and manually erase that line.

In fact, you should just go ahead and erase any line that points to any provisioning profiles. Then reopen the project in Xcode, go to the settings and reselect your new profile. This clears up issues like that most of the time.

The lines that point to the provisioning profiles will look like this:

PROVISIONING_PROFILE = "487F3EAC-05FB-4A2A-9EA0-31F1F35760EB";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "487F3EAC-05FB-4A2A-9EA0-31F1F35760EB";

The .xcodeproj file is actually a directory, like an application bundle, If you right click it in finder, you can select show package contents, and then you will see several files inside (or in terminal just cd into it). The actual project file is the one in there with a .pbxproj extension. Once you open it with a text editor the lines you are looking for should start with 'PROVISIONING_PROFILE = or' '"PROVISIONING_PROFILE[sdk=iphoneos*]" ='. Delete all of those and then you should be good.
I found that, in addition to the above, I had to delete all of my profiles, re-download them from the provisioning portal, and reimport them into XCode. Then, in Build Settings / Code Signing, select the proper profile for all build configurations.
Still a valuable advice with XCode4 in 2012. Thanks!
...aaaaand still valuable advice with Xcode6 in 2014! Thank you very very much!
The only thing that worked for me: Preferences -> Accounts -> View details -> Refresh. That reloaded all of the provisioning profiles from dev portal. Hope this helps someone
s
shim

Here's a simpler solution that worked for me and which doesn't require the manual editing of the project file:

In Xcode, in the "Groups & Files" pane, expand "Targets" and double-click on your app's target. This brings up the Info pane for the target. In the "Build" section, check the "code signing" section for any old profiles and replace with the correct one.

Note that this is different from double-clicking on your project icon and changing the profile from there. Quite amazing :)

Ori


Thanks! I'll try this next time it happens :)
and make sure to select the right build configuration first :)
This doesn't always work. Sometimes you still have to go in and change it manually like it shows in the first answer.
Just another note to echo SpaceTrucker: this method doesn't always work. The accepted answer guarantees that Xcode will stop looking for that phantom profile.
I found that, in addition to the above, I had to delete all of my profiles, re-download them from the provisioning portal, and reimport them into XCode. Then, in Build Settings / Code Signing, select the proper profile for all build configurations.
u
user732414

Project&Targets Properties -> "Don't Code Sign" -> OK -> cmd+S(or cmd+B); Project&Targets Properties -> "Your Provision Profile"-> OK Everything works again!


This is the only solution that worked for me (Using XCode4). Building the app with "Don't Code Sign" selected was a mandatory step for me.
This seems like a better solution than the one with 200+ upvotes, because Xcode might change the way it writes its project file in future.
This is the correct sollution which worked for me in Xcode 4.2
B
Brad The App Guy

I agree with Brad's answer, that you can fix this problem by editing your target/project by hand, deleting any lines like this:

PROVISIONING_PROFILE = "487F3EAC-05FB-4A2A-9EA0-31F1F35760EB";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "487F3EAC-05FB-4A2A-9EA0-31F1F35760EB";

However, in Xcode 4.2 and later, there is a much easier way to access this text and select and delete it. In the Project Navigator on the left, select your project (the topmost line of the Project Navigator). Now simply choose View > Version Editor > Show Version Editor. This displays your project as text, and you can search for PROVISIONING and delete the troublesome line, right there in the editor pane of Xcode.


Following this you don't have to close and open project. Better approach :)
s
shim

Just saw a variation on this issue: I went into the project.pbxproj file as per Brad Smith's notes above, except in this case all of the PROVISIONING_PROFILE lines seemed to be correct, with no occurrence of the "bad" profile string that Xcode couldn't find.

However, the fix was the same: deleting ALL of the PROVISIONING_PROFILE lines in project.pbxproj, even though they looked "good" in theory, and then reopening the project in Xcode.


M
MechEngineer

To achieve Brad's solution entirely in Terminal, use these commands

cd [Xcode project parent] vi [Xcode project name].xcodeproj/project.pbxproj /[offending provisioning profile] [Enter] dd - delete the entire line Press n until no more are found Ctrl+x to save and close


s
stack-o-frankie

In my case the problem was solved by opening Window -> Organizer, selecting my device and removing the old Provisioning Profile under the "Provisioning" panel on the right. The old one was already marked with a red "x" symbol but the iPhone was still using it.

Besides that profile, also the new one was showing up (with the same name) and after simply relaunching the application I had it running smoothly.


+1, sometimes I've been unable to install because an expired profile - not even with the same identifier! - was on my device.
This one worked for me, but I also had to relaunch XCode to get it working.
b
bobbypage

Just spent a hour or so doing this and with the help of Brad's advice and a few additional changes it all worked.

I've done this using the following: 10.7.3, Xcode 4.3.2, iOS 5.1 btw.

1) Right click on your myapp.xcodeproj and select package contents

2) open project.pbxproj with a text editor (don't recommend textedit as it may screw up the formatting)

3) Scroll all the way down until you find /* Begin XCBuildConfiguration section */

4) Notice that you have a debug and release sections

5) In the release section take a look at CODE_SIGN_IDENTITY & "CODE_SIGN_IDENTITY[sdk=iphoneos*]" it should look something like this:

CODE_SIGN_IDENTITY = "iPhone Distribution: MyCompany LLC";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution: MyCompany LLC";

6) Take a look at PROVISIONING_PROFILE and "PROVISIONING_PROFILE[sdk=iphoneos*]" they should look like this:

PROVISIONING_PROFILE = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";

This should match your provisioning profile in Xcode. To see if they match open Xcode > Window > Organizer > Devices > Provisioning Profiles > Right click on the profile > Reveal in Finder > The filename of the .mobileprovision is your profile id.

7) Scroll down in the project.pbxproj and find a second instance of the release section. The second instance of the release section should end with a comment saying /* End XCBuildConfiguration section */

8) make sure that the second section matches the first section so that CODE_SIGN_IDENTITY, "CODE_SIGN_IDENTITY[sdk=iphoneos*], and PROVISIONING_PROFILE are all filled in.


R
Richard Brown

One suggestion I'll make since no one yet has said it: PLEASE PLEASE PLEASE make a backup of your whole .xcodeproj file BEFORE you start modifying it's contents. Screwing up the project file and having no backup will lead to a very very unpleasant experience.

Being able to back out of an edit can be a godsend.


Yes, this is why the SCM gods made source control.
s
sunkencity

Select the lines in codesigning that are blank under Any iOS SDK and select the right certificate.


j
jean_jean

The solution of Brad Smith worked for me, but I also had to remove the CODE_SIGN_IDENTITY field to make it work.


This is done manually by modifying the xcode project file in a text editor, and I have often had to do this to get going again when I get into a broken state. Knowing both things that can be removed is often very helpful. Good point.
s
shim

I just encountered this problem in my Xcode 4. To fix it, you need to put all the correct provisions into both Debug and Release config.

I was trying to submit (by archiving) my app. So I just change the Debug provisions to "Don't Code Sign", and the Release provision to my app's appstore provision.

This fix it and enables me to archive normally. Hope that helps.


C
Community

Unfortunately this approach didn't work out for me. But here's a fix which worked for me (to get this to work you need a working project file on Subversion or so):

I did roll back to an working version of my project file. As it isn't possible to revert with Xcode (Where is the 'Revert' option in Xcode 4's Source Control?) - I used Tortoise, my Windows machine and this Tutorial (http://tortoisesvn.net/docs/nightly/TortoiseSVN_en/tsvn-howto-rollback.html) to roll back to an older project file.

As the Tutorial didn't work out for me, I just used Tortoise to save the working revision of my project file to an usb stick to port it to my mac. After that I replaced the new broken project file with the old working one, cleaned and it worked like a charm!


R
RawMean

At least in Xcode 5, this is the thing that solved the problem for me:

Under provisioning profile, select the offending provisioning profile and then select a valid provisioning profile in the pull-down menu.

https://i.stack.imgur.com/1lfqG.png


a
annu

You Could remove old reference of provisioning file. Then after import new provisioning Profile and selecting Xcode builder.


s
shim

I was having issues because I updated my AdHoc provisioning profile with some new devices for use on TestFlight. Assumedly this is happening because Xcode has an old reference to your provisioning profile in either the codesigning build settings for the project or the targets. The way I fixed mine was to:

Go to both target build settings and project build settings, Under code signing change all the provisioning profiles to something else. Go to devices/provisioning profiles in the Organizer delete the offending profiles, then click the refresh button in the bottom right. Go back to to the target and project build settings and set your provisioning profiles to the appropriate (hopefully) newly refreshed provisioning profiles.