Wednesday, January 7, 2009

CodeSign error: a valid provisioning profile is required

"CodeSign error: a valid provisioning profile is required for product type 'Application' in SDK 'Device - iPhone OS 2.2"

This error will appear when you update your provisioning profile in iPhone SDK 2.2
or after the expiration of developer certificate and that you have a new provisioning profile from the developer portal

This is the solution (which is modified from http://www.furmanek.net/54/iphone-sdk-22-codesign-error/)

Suppose you have copied your provisioning profile called "iPhone_Development.mobileprovision" to the Library folder and build & go an old iPhone project called "MyApp", and this annoying error appears

(1) cd ~/Library/MobileDevice/Provisioning\ Profiles/

(2) find out the UUID of the provisioning profile
strings iPhone_Development.mobileprovision | grep "<string>.*-.*</string>"

output is like this
<string>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</string>

(3) copy that UUID between the string tag

(4) close xcode and go to your project
cd ~/Projects/MyApp/MyApp.xcodeproj

(5) Use a text editor to open the project.pbxproj
find the string PROVISIONING_PROFILE

paste the UUID that you copied from step (3) and put it in both Debug and Release Sections (do multiple finds) for the following line
e.g.
PROVISIONING_PROFILE = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";

(6) Launch XCode and open the project and build & go again


Updates :
Deleting all of the lines "PROVISIONING_PROFILE" in project.pbxproj will also fix the problem for iPhone SDK 3 or above





41 comments:

  1. You're my hero !!!!!!

    ReplyDelete
  2. Thanks so much. This came up in a Google search for the error string and it's been a great help -- the last step I needed before getting my app to run on my iPod Touch. The only info to add is that users should do multiple finds for PROVISIONING_PROFILE, as my pbx file had four separate instances that needed fixing.

    ReplyDelete
  3. Very very helpful.

    ReplyDelete
  4. A million thanks. I was putting off trying to fix this problem, and you just saved me countless hours of frustration. I even cleaned up a bunch of old, useless PROVISIONING_PROFILE lines while I was there.

    ReplyDelete
  5. The PROVISIONING_PROFILE settings may be vestigial. New projects don't acquire them and simply deleting them fixed it for me; your mileage may vary. Nice of Apple to exclude these from the Info panes. >:-(

    ReplyDelete
  6. Thank you! That helped me a lot :D

    ReplyDelete
  7. I can't imagine how long this would've taken me to fix without this post. Your blogging is much appreciated.

    ReplyDelete
  8. Awesome, thank you so much!!!

    ReplyDelete
  9. Add me to the "exceptionally grateful" list. The problem apparently still exists with SDK 2.2.1. I had to update the provisioning profiles to add a developer and all heck broke loose until I found this.

    I can stop restoring iPhone now.

    ReplyDelete
  10. Doood.... Deleting all of the lines fixed it for me. Thanks a million!

    ReplyDelete
  11. I have the same problem but I can't find the project.pbxproj file. Where is it?

    ReplyDelete
  12. It worked!!!! Thank you so much. Now, if you could help me with CSSMERR_TP_NOT_TRUSTED error message that would be perfect. Thanks again.

    Adrian

    ReplyDelete
  13. You're a life saver this has been screwing me up for a few days now.

    ReplyDelete
  14. I'm also very grateful for your post. I can't believe Apple has made it this hard just to change provisioning profiles! I can't wait until I start pushing out beta copies of my app...

    ReplyDelete
  15. Fantastic! So glad I found this...

    ReplyDelete
  16. Wow, I was going crazy until I found this and now I finally can test my app on my iPhone again. Thanks so much!!

    ReplyDelete
  17. Thanks a ton... fixed the problem beautifully. I wouldn't have had a chance of finding it if you hadn't posted this.

    ReplyDelete
  18. In the project file it appears that there are 2 sets of build configs (PBXProject, PBXNativeTarget). When my partner modified the provisioning profile and updated the project for it, it appears that it affected only one of these 2 sets.

    So when I did "Get Info" on the target object in the project window, I saw an incorrect/vestigial entry in the Build tab for the code signing identity with the old profile UUID. When I just selected the correct one in the menu, it worked. I have no explanation for how it worked like that in my partner's setup...

    ReplyDelete
  19. Worked with me. Using XCode for OS 3 beta 4. Thank you!

    ReplyDelete
  20. Thanks a lot! I have to use it a lot, please keep this site online :)

    ReplyDelete
  21. incredible awesome post searched the web for hours without avail first class!

    ReplyDelete
  22. It worked for me too, Much Thanks !

    ReplyDelete
  23. Thanks for this. Definitely helped when changing profiles.

    ReplyDelete
  24. Add me to the "exceptionally grateful" list, too!!! Spend hours before finding your extrem helpful link. THX!

    ReplyDelete
  25. I love you! i love internet! :-))))))))

    4 hours lost in my live and in this post i find the solution!!

    Thanks!!!

    ReplyDelete
  26. Thank you so much! I lost a whole bunch of time over this, and kept creating and recreating new certificates and provisioning profiles to try and solve it.

    I just deleted all the PROVISIONING_PROFILE lines and it started compiling! Thank you!

    ReplyDelete
  27. Thank you thank you thank you.

    ReplyDelete
  28. Thanks so much - you just saved me a huge amount of work. You're a god!!!

    ReplyDelete
  29. Does not work with iphoneOS 3.1.2. Anyone accomplished deleting PROVISIONING_PROFILE worked with xcode 3.1.4 and iphoneOS 3.1.2? Im on 10.5.8 iAtkos. thanks

    ReplyDelete
  30. YOU ARE A GENIUS!!!!!!
    You saved me so many hours.... umbelivable!
    Thanks!!!

    ReplyDelete
  31. I also had to change lines of the form:
    "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Don't Code Sign";

    to

    "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";

    as it appeared there were duplicated sections and it did not seem possible to do so from within xcode. (don't ask why as this was for a 3rd party project I downloaded from a book)

    ReplyDelete
  32. Thank you!!! This has saved me twice.

    ReplyDelete
  33. Works like a charm! Wonderful. I wasted one day in fixing this & finally found this to work.

    Thanks a ton.

    ReplyDelete
  34. Works on IOS4 also...

    I would note that on yourApp.xcodeproj you have to right click and "Show Package Contents" to see the project.pbxproj file.

    Also, I didn't delete the lines with PROVISIONING_PROFILE in them. I had...

    "PROVISIONING_PROFILE[sdk=iphoneos*]" = "";

    ...and replaced "" with my correct profile.

    Thanks a million!!!

    ReplyDelete
  35. Thanks for the nice information. I am sure, I will tweet this to my twitter account. This will help a lot of users.

    ReplyDelete
  36. Select xcodeproj in xCode 4. Under "Build Settings", find the "Code Signing" section and choose your developer certificate. Swoosh! The error disappears

    ReplyDelete
  37. Nice Post. Thanks for sharing

    ReplyDelete