Codesign error: Provisioning profile cannot be found after deleting expired profile
Asked Answered
A

16

504

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.

Ailbert answered 19/11, 2009 at 2:28 Comment(0)
A
859

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";
Aric answered 19/11, 2009 at 3:39 Comment(11)
Thanks for the reply. I got an error "The document could not be opened" trying to open the .xcodeproj file with TextEdit (just restarded and Xcode is not running). Any idea?Ailbert
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.Aric
Brad Smith I've tried to archive my app with a new provisioning profile and Xcode looks for old provisioning. I've tried what you said and workDried
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.Kidskin
Still a valuable advice with XCode4 in 2012. Thanks!Socioeconomic
Got this problem in Xcode 4.4 after updating the Provisioning profiles in the Organizer and making an Ad-Hoc Distribution build/archive. The above solution fixed it.Naumachia
Ran into this error when upgrading xcode 4.6 to xcode 5. Editing the file fixed the error.Ypres
...aaaaand still valuable advice with Xcode6 in 2014! Thank you very very much!Renayrenckens
I wasted a morning tracking this issue down (and THEN came across this exact advice !!) As Tom said, this pathetic bug is alive and kicking in the latest XCode 6.1 (November 2014). Apple REALLY doesn't like developers, does it?Bumper
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 someoneDeice
Still going strong in '16. This saved me so much frustration.Donnadonnamarie
C
129

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

Colcannon answered 7/6, 2010 at 9:22 Comment(8)
Thanks! I'll try this next time it happens :)Ailbert
and make sure to select the right build configuration first :)Ambulance
This doesn't always work. Sometimes you still have to go in and change it manually like it shows in the first answer.Realty
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.Deloisedelong
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.Kidskin
worked for me, actually double-clicking the project to get to that window (xcode 4.5.1)Michele
Ah! Thanks, @WarrenP, I kept looking for this solution's steps in XCode 4.6 and I was perplexed. Unfortunate that this answer doesn't have better steps or screenshots.Tierratiersten
I can't find "Groups & Files" pane, using XCode 4.6.3. This would be great solution if explained more with which version to use.Vetavetch
C
77
  1. Project&Targets Properties -> "Don't Code Sign" -> OK -> cmd+S(or cmd+B);
  2. Project&Targets Properties -> "Your Provision Profile"-> OK

  3. Everything works again!

Closer answered 18/5, 2011 at 21:58 Comment(3)
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.Copal
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.Harter
This is the correct sollution which worked for me in Xcode 4.2Lecce
P
11

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.

Progress answered 23/11, 2012 at 17:34 Comment(1)
Following this you don't have to close and open project. Better approach :)Burp
C
7

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.

Concealment answered 4/5, 2011 at 3:24 Comment(0)
W
5

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

  1. cd [Xcode project parent]
  2. vi [Xcode project name].xcodeproj/project.pbxproj
  3. /[offending provisioning profile] [Enter]
  4. dd - delete the entire line
  5. Press n until no more are found
  6. Ctrl+x to save and close
Wriest answered 17/4, 2012 at 18:48 Comment(0)
T
4

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.

Thick answered 10/11, 2010 at 12:1 Comment(2)
+1, sometimes I've been unable to install because an expired profile - not even with the same identifier! - was on my device.Ailbert
This one worked for me, but I also had to relaunch XCode to get it working.Starfish
L
4

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.

Lorrimor answered 14/4, 2012 at 9:1 Comment(0)
T
2

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.

Toadstool answered 17/8, 2011 at 17:39 Comment(1)
Yes, this is why the SCM gods made source control.Breadroot
S
1

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.

Strawboard answered 19/8, 2011 at 0:42 Comment(0)
V
1

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

Vanhouten answered 18/11, 2011 at 15:12 Comment(0)
M
1

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

Mailman answered 19/11, 2012 at 15:59 Comment(1)
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.Shetler
L
0

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!

Leuctra answered 7/2, 2013 at 9:14 Comment(0)
S
0

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:

  1. Go to both target build settings and project build settings, Under code signing change all the provisioning profiles to something else.
  2. Go to devices/provisioning profiles in the Organizer delete the offending profiles, then click the refresh button in the bottom right.
  3. Go back to to the target and project build settings and set your provisioning profiles to the appropriate (hopefully) newly refreshed provisioning profiles.
Sweat answered 25/6, 2013 at 20:16 Comment(0)
M
0

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.

enter image description here

Margy answered 26/9, 2013 at 1:26 Comment(0)
R
0

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

Roca answered 9/3, 2015 at 12:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.