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

138,841

Solution 1

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";

Solution 2

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

Solution 3

  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!

Solution 4

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.

Solution 5

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.

Share:
138,841
quantumpotato
Author by

quantumpotato

Smart contract, game, backend business logic, iOS & Android developer. I started programming videogames in BASIC at 8 years old. This led me to explore Visual Basic and pursue game design. I worked for GoPets doing Q&A & minigame design in Seoul in 2005 and worked as a Game Designer for the leading MMO technology solution, Bigworld Tech in Sydney from 2006-2008. After returning to the USA, I taught myself iPhone development and became involved in the local Houston iPhone Developer's Meetup. I did third-party app development & entered an all-night coding competition and won with a game developed. From that, leading app development studio ChaiONE offered me a job as a programmer. I worked there for 2 years before moving to Chattanooga to work with a startup company in the inaugral 2012 Gigtank Startup Accelerator Program sponsored by LaunchTN's CoLab. Since then I have been freelancing iPhone, Android & Backend Server development. I've worked with technologies including GPS, SMS phone services, integrating with credit card processing hardware, federal government app development, non-profit app development, debugging existing server code, leading a game development team, consulting for a software-defined concussion diagnostic tool and more. Clients include ChaiONE, CoLab, Bluelance, Rice University, Spartan Systems, GS&F. I am looking for projects related to app development, technical consulting, code reviews, game design & game development. Thank you for your time reading and I look forward to working with you.

Updated on December 24, 2020

Comments

  • quantumpotato
    quantumpotato over 3 years

    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.

  • quantumpotato
    quantumpotato over 14 years
    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?
  • shiva kumar
    shiva kumar over 14 years
    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.
  • quantumpotato
    quantumpotato almost 14 years
    Thanks! I'll try this next time it happens :)
  • Johnus
    Johnus over 13 years
    and make sure to select the right build configuration first :)
  • Admin
    Admin about 13 years
    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 work
  • quantumpotato
    quantumpotato about 13 years
    +1, sometimes I've been unable to install because an expired profile - not even with the same identifier! - was on my device.
  • Chazbot
    Chazbot almost 13 years
    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.
  • Matt
    Matt almost 13 years
    This one worked for me, but I also had to relaunch XCode to get it working.
  • SpaceTrucker
    SpaceTrucker over 12 years
    This doesn't always work. Sometimes you still have to go in and change it manually like it shows in the first answer.
  • Simone Manganelli
    Simone Manganelli over 12 years
    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.
  • Danyal Aytekin
    Danyal Aytekin over 12 years
    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.
  • Jay Imerman
    Jay Imerman over 12 years
    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.
  • Jay Imerman
    Jay Imerman over 12 years
    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.
  • Selvin
    Selvin over 12 years
    This is the correct sollution which worked for me in Xcode 4.2
  • Alexey Rusakov
    Alexey Rusakov over 12 years
    Still a valuable advice with XCode4 in 2012. Thanks!
  • Br.Bill
    Br.Bill almost 12 years
    Yes, this is why the SCM gods made source control.
  • Wollan
    Wollan almost 12 years
    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.
  • Marc Lindahl
    Marc Lindahl over 11 years
    worked for me, actually double-clicking the project to get to that window (xcode 4.5.1)
  • viral
    viral about 11 years
    Following this you don't have to close and open project. Better approach :)
  • Danny
    Danny almost 11 years
    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.
  • Warren  P
    Warren P almost 11 years
    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.
  • Ska
    Ska almost 11 years
    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.
  • kzia
    kzia over 10 years
    Ran into this error when upgrading xcode 4.6 to xcode 5. Editing the file fixed the error.
  • Tom van Zummeren
    Tom van Zummeren over 9 years
    ...aaaaand still valuable advice with Xcode6 in 2014! Thank you very very much!
  • Mike Gledhill
    Mike Gledhill over 9 years
    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?
  • blackhawk4152
    blackhawk4152 over 9 years
    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
  • LulzCow
    LulzCow almost 8 years
    Still going strong in '16. This saved me so much frustration.