how to fix iphone code signing errors

January 4, 2009

This post is a collection of all code signing solutions, including my suggestions, in one place.

You can find fixes for issues like:

  • distribution profile not showing up in xcode
  • packaging is using the wrong folder
  • no packaging or code signing done during build
  • code signing with the wrong certificate
  • error during app upload saying the app has been signed with invalid certificate

If you are experiencing any of these issues, please read on…

I apologize in advance for the lengthy discussion… I’ll probably create a cliffnotes version of the best solution at some point.

NOTE: in the 2.2 version of the SDK, the Code Signing Identity and Provisioning Profile settings have been merged, so you set both in the Code Signing Identity field. I usually call out both settings in this post to be backwards compatible, if you are using 2.2+ SDK just ignore the Provisioning Profile filed in the screenshots and text. I actually preferred the old way, becuase I have multiple profiles and now all I see in the settings is iPhone Distribution: Your Name. To see what profile is being used I actually have to click on the field to bring up the list. Insane.

You should really read the whole thing. If you are here, you’ve probably already spent hours or even DAYS code signing. It’s easier to fight the evil if you know more about it.

But if you are in a hurry, jump to Sanity checks then to Exercise 4.

<rant alt=”highly therapeutic”>

Just so you know you’re not alone.

Last week I added some features to sketchinz, one of my iphone apps. Everything went fabulously: my classes are well designed and I am quite comfortable with the specific part of the sdk so it was as easy as it would be for Joe the Plumber to hook up the hot water to the hot water and the cold water to the cold water.

I was on a roll, all done in 30 minutes. A quick look at the clock: 11:30pm. I’ll quickly package it all up, submit my update, and pick out a dark comedy on Netflix instant watch…

Little did I know that for the next two hours I will be beaten, cubed and ground into hamburger meat by Apple engineering’s probably most ingenious attempt to one up Turing’s theory of the “halting problem”: code signing.

This was supposed to be easy: the certificates were correct and installed. I’ve successfully signed and posted this app before. I haven’t changed any build settings. The certificates are still valid. I read the manual. I followed each step. I can make a wedding cake from scratch. I can even make sausage from scratch.

wedding cake and sausage made by me

wedding cake and sausage made by me

Apparently Apple knows that code signing has issues. There are some suggestions on the program portal to fix code signing (as in delete all information, restart and retype all information- feels like reading a Windows 3.0 manual.) So why don’t they fix it? Good question. Maybe they read this post, get angry and fix it…

I mean how hard can this be? Look up two field values and execute a script with those arguments? Geezus. In fact I have another question:

Why do developers have to bother with code signing at all? Why are the apps not automatically signed when uploaded to the store?

Now that I’ve got it all out let’s look at some solutions after we reread the first step of code signing anonymous:

Step One: We admitted we were powerless over code signing – that our lives had become unmanageable.


These solutions assume that you have valid certificates and the certificates are installed. Before we get too far into it, let’s do some:

Sanity checks

1. Make sure your keychain has the Apple WDR certificate, your distribution certificate and under it the private key used to create the certificate. This is best checked by setting the Category to Certificates. Click the triangle next to the certificate to see your private key. You should see something like this:

keychain certificate view

keychain certificate view

* If you don’t have a private key (no triangle) because you got a new computer, reinstalled osx, or are using your boyfriend’s computer and you have not exported your private keys (hint, hint, hint -> export your private keys now), you’ll need to throw away all your certificates and provisioning profiles and create new ones on the program portal.

* I figured I could blur my name on the images, but then you could just scroll up a bit and see it anyway. So I decided to not go through the hassle.

2. Make sure that the provisioning profiles show up in the {YOUR_HOME_DIRECTORY}/Library/Mobile Provisions folder. The profiles might have the original name as you downloaded them from the program portal or they might have been renamed to their ids if you installed them by dropping on xcode. They will work either way.

provisioning profiles folder

provisioning profiles folder

3. This is just a suggestion: I create wildcard app ids for all my apps so I don’t have to worry about the Identifier setting in the Target Info / Properties tab. You can leave the default string: “com.yourcompany.${PRODUCT_NAME:identifier}”, or you can change it to whatever you want. To create a wildcard app id in the program portal, just put an asterix in the App ID field as below:

wildcard app id

wildcard app id

Ok, let’s look at the first evil.

“distribution profile not showing up”

The Distribution configuration is created by duplicating the Release configuration. At the target level enter iPhone Distribution: Your Name in the Code Signing Entity field. When you click on the Code Signing Provisioning Profile field value, you should see something like this (sketchinz profile showing):

distribution profile showing

distribution profile showing

Sometimes, however, you are presented with no provisioning profiles like this:

distribution profile not showing

distribution profile not showing

Before we go much further, let’s do some easy checks:

1. Make sure you have the Distribution configuration set active.

distribution configuration active

distribution configuration active

2. Make sure you are modifying the Distribution configuration.

modifying distribution config

modifying distribution config

2. Make sure there’s no typo. The code signing identity field should match the name of your certificate in your keychain. It’s case sensitive.

3. Make sure that there is one space between “Distribution:” and “Your Name”.

4. There should be no space before “iPhone” and no space after “Your Name”.

Excercise #1

Leave your project open in xcode and create a new project. Create a Distribution configuration, enter iPhone Distribution: Your Name in the Code Signing Identity field and see if your profiles show up here. If they do, it’s your lucky day because most likely they will show up in your original project now.

I think this was originally suggested at in this post.

Excercise #2

1. Do a “Clean All” in your project.

2. Delete the value in the Code Signing Identity field.

3. Exit xcode.

4. Go to the build folder for your project and delete everything. (Especially the folder called {YOUR_PROJECT_NAME}.build.) The build folder is usually located right in your project’s folder, if it’s not there you can find the loction in the project’s info window under the General tab.

5. Restart xcode, fill in Code Signing Identity and see if your profile shows up. If it does, it’s your lucky day.

6. If it doesn’t you can try this again, but restart your computer before restarting xcode. If your profile shows up now, it’s your lucky day.

This method is suggested on the program portal by Apple.

Exercise #3

It’s possible to set a value for the Code Signing Identity and Provisioning Profile at both the Project and Target level. And it’s possible to set different values in two places!

In theory this should not be a problem. If a value is not set at the Target level, it falls back to the value at the Project level. If a value is set at both places, the Target level value should have priority.

It seems however that xcode sometimes gets, hmm, confused. In fact if you followed the directions from the program portal, you will have iPhone Developer set at the Project level and iPhone Distribution: Your Name at the Target level for the identity.

Set the identity to iPhone Distribution: Your Name at the Project level. If your profile shows up, it’s your lucky day.

If not, do a Clean All, exit xcode, delete the contents of the build folder and restart xcode. If your profile shows up, it’s your lucky day.

Most likely by now your distribution profile shows up. If not, the move on to the next exercise that should also help with:

“no packaging or code signing during build”

“code signing with the wrong certificate”

Exercise #4

The program portal instructs to verify code signing by looking at these two lines in the build out

ProcessingProductPackaging “/Users/lajos/Library/MobileDevice/Provisioning Profiles/sketchinz.mobileprovision” /Projects/iPhone/deleteme6/build/Distribution-iphoneos/ …

CodeSign /Projects/iPhone/deleteme6/build/Distribution-iphoneos/
cd /Projects/iPhone/deleteme6
/usr/bin/codesign -f -s “iPhone Distribution: Lajos Kamocsay“…

By the way to look you can look at the build output in the build tab (shortcut: command+shift+B) by clicking this button:

xcode build output

xcode build output

Your app is correctly signed when:

1. product packaging uses the correct provisioning profile

2. product packaging outputs the embedded.mobileprovision into the correct .app build folder

3. code signing uses the correct identity

On a side note, I suggest installing the provisioning profiles by manually copying them into the {YOUR_HOME_DIRECTORY}/Library/Mobile Provisions folder rather than dropping them on xcode because when dropped on xcode the files are renamed to their ids. If you copy them by hand the file name will remain consistent with the build settings and the build output. (You can open up the certificates and look at the ids by the way, but why bother with remembering hex values at 3 in the morning.)

So how can xcode use the wrong certificates?

As discussed in Exercise #3, the Code Signing Identity and Provisioning Profile can be set at both the Project and Target levels. If the values are different, xcode seems to get conused sometimes. In my experience fixing the discrepancy had sofar eliminated the code signing issues from above. (There is one more issue coming later, the most evil of them all that needs even worse measures.)

In this exercise I will suggest something contrary to the instructions on the program portal. Instead of setting the Code Signing Identity and Provisioning Profile at the Target level, we’ll only set them at the Project level. The Target(s) will inherit the settings the Project and life will be as sweet and naughty as chocolate cake.

1. Make sure that there are no values set in the Target Build info. Xcode displays values set here in bold:

xcode target set

xcode target set

(You can also set the Show option to Settings Defined at this Level, and you want to make sure that Code Signing Identity and Provisioning Profiles don’t show up there.)

2. To reset them, select the line where the value shows up and hit the ‘delete’ key.┬áBoth values should now appear in normal font weight:

xcode target unset value

xcode target unset value

3. Go to the Project Build info, and set the Code Signing Identity and Provisioning Profile.

xcode project distribution profile set

xcode project distribution profile set

4. You might need to do the magical xcode voodoo dance of “Clean All”, exit, delete everything in the build folder and restart xcode, but by now that should be second nature. Kind of like washing hands before one touches its own self.

The only situation this approach would not work conveniently is if there were multiple targets all with their own provisioning profile. I have no idea why anyone would impose such hell on hirself.

In fact, I have no idea why the hell would anyone use a non-wildcard app ids. I guess some people like self torture while some others are following stupid arse executive orders. If you are using non-wildcard app ids and don’t fall into either of those categories, this is your chance to redo your profiles with wildcard app ids (discussed somewhere above.)

And now let’s look at the worst of them all:

“product packaging uses wrong .app build folder”

Exercise #5

This one is pretty easy to recognize. The .app build folder on the product packagin line is pointing to a different configuration (eg. Release) or a completely different .app.

The only solution I’ve found for this one is to:

1. duplicate the target

xcode duplicate target

xcode duplicate target

2. delete the old target

3. rename the new target (take the ” copy” off the end)

4. when duplicated, xcode creates a copy of the Info.plist file. To fix, go to the Target Info, select all configs, and search for info -> change Info copy.plist back to Info.plist. (You should also delete the Info copy.plist file from Resources.)

xcode target info copy.plist

xcode target info copy.plist

Now try to “Clean All”, delete old builds and restart xcode. Cross the fingers and build.

“no ProcessingProductPackaging line in build output”

This solution comes from Jonathan Mulcahy. Here’s his discription of the problem:

The app builds fine and runs on my iPhone fine. When I try to build
the Distribution app, it builds fine with no errors, but when I look
at my build log, I do have the CodeSign entry, but there is no log
entry for ProcessingProductPackaging part, so the 
embedded.mobileprovision does not exist.

He also noticed that in the Code Signing Identity options it said “All Code Signing Certificate Identites” instead of the name of the mobileprovision. (click on image to see full size)

missing mobileprovision name

missing mobileprovision name

You should see the name of the mobileprovision, like in this case sketchinz:

mobileprovision name showing

mobileprovision name showing

So the solution:

Exercise #6

Remove the iphone SDK and reinstall it, preferably the latest version (at this time 2.2.1).

Thanks Jonathan for this contribution!

Final thoughts

  • don’t give up- it will work
  • feel free to contact me if you are still stuck or have any additional info to share with the world

74 Responses to “how to fix iphone code signing errors”

  1. @Bogatyr: Make sure that your test user installed the .mobileprovision file on hos phone. He can check that on the phone in Settings / General / Profiles. He does not need the WWDC certificate, but you need that installed on the computer where you are making the build.

  2. I’m having a particularly peculiar case. I am doing an Ad Hoc distribution, and have successfully built and installed our app on multiple phones using an add hoc mobileprovision file and a distribution build built with it. Everything works fine.. until we get the the VP’s iPhone. When he attempts to install the app via sync to iTunes he gets “the application signature is not valid” message.

    With all previous users i modified my mobileprovision to add new devices but was able to send the modified mobileprovision along with the original app build and the users are able to install successfully.

    With our VP, i haven’t been successful even after rebuilding the app using the modified mobileprovision containing their device ID.

    Their iPhone is from France. Does this perhaps have anything to do with the issue I am facing? I am at a loss so far as it installs successfully on 4 other iphones synced from both PCs and Macs.

  3. @ch-apps: That sounds weird. I can only think of two things: the persone didn’t give you the correct ID, or he’s not installing the certificate correctly. Ask him to make sure that the profile shows up in his device in Settings / General / Profiles. Maybe you can even ask him to delete the profile in the same menu and reinstall it.

  4. New to Mac. Learning C, Objective C and iPhone Development all at once. First iPhone app development going well, simulator trials running well. All of sudden a build results in the message that got me to these posts: Code Sign error: The identity: ‘iPhone Developer’ doesn’t match any valid certificate/private key pair in the default keychain. I don’t mind doing some hard work but any clues ehre to start? What did I do wrong. Never did anything but change .h and .m files using XCode and IB. Any help much appreciated. JS

  5. @John: You need to create a developer certificate and install it on your keychain. Go to, login and click on the iPhone provisioning portal on the right. You will also need to install the wwdc certificate, but there are instructions for that on that page. I assume you already paid the $99 (otherwise you can’t do this).

  6. Thanks so much for these pointers. Wasn’t seeing either the productpackaging line nor the codesigning. Tried setting project and target profiles to match and still same. Reinstalled iphone SDK still same. Went into target info and deleted the line for the provision profile and all works now.

  7. Actually it seems the previous problems I had weren’t due to the profile mismatches. I was previously building with the iPhone simulator selected as the device instead of the physical iPhone device. All sorted now.

  8. I just wanted to thank you for the advice. Exercise 3 solved a major headache for us today.

  9. Hi Lajos,

    I’ve just spent a day and a night tearing my hair out trying to get AdHoc distribution working for our beta testers.

    I came across this excellent post and would like to take you up on the offer of help.

    The error I’m getting when users try to install the ad hoc app is :

    “The application XXX was not installed on the iPod yyy because it is not compatible with this iPod”

    I have been through all the steps in your post – search every google result I can think off. I even started with a brand new project that just does a “Hello Would” and went through the whole process again – still with the same result!

    App builds fine – the correct provisioning profile is being used in build results. The mobile provision is installed on the device and everything works in debug and release modes.

    I’m really stuck now and not sure where to go next.

    Any help, ideas or pointers would be most gratefully received!

    Many thanks


  10. @Matt: Are you sure this is a code signing error? Do your users have the same version (or newer) iphone os you are building for?

  11. Thanks for getting back to me. I think I finally resolved the problem about 10 mins ago – I’m just waiting on feedback from beta testers now.

    I think I tracked the problem down to an entry in the Info.plist. The weird thing was that this only occurred when trying to do an Ad Hoc distribution, hence my suspicion that it was a code signing problem.

    In the end I deleted all the certificates, device IDs and provisioning profiles from the portal, my Mac and iPod and started again from scratch. Your post was invaluable here in both guiding the process and helping me overcome the fear of permanently breaking something!

    I also cleared out my Keychain, uninstalled XCode and downloaded the latest version of the SDK and XCode.

    Somewhere along the line this gave me a much better error report when building that pointed to the “UIRequiredDeviceCapabilities” entry in the info.plist. Although I cleared all the options (no need for camera, accel, etc) it still gave me compatibility problems. In the end I deleted the whole key “UIRequiredDeviceCapabilities” and the problem disappeared.

    Thanks again for the help and all the best.

  12. help

    Code Sign error It’s Not Working show me 1 failed

    Code Sign error: The identity ‘iPhone Distribution’ doesn’t match any valid certificate/private key pair in the default keychain

    i build app before no problem I don’t know wats wrong with my keychain
    I have both the Development and Distribution certificates in my keychain and they are both valid

    i change leopard to snow leopard

  13. When I bought my ipad I registered it with my personal itunes account. Then I joined the developer program and used a different account.
    I am trying to deploy my app to my ipad but I am getting an error in Xcode saying that it can’t find a valid certificate for the profile. I have followed all the steps of generating a cert on the keychain, submitted it to the apple website, and then downloaded the cert, created a provisioning profile and downloaded it.
    My only guess is that my ipad was registered with a different account than the one I am generating the certs/profiles with. Could this an issue? Should I reset my ipad and register it with my developer account?

  14. @Brandon: No, that should be no issue. You can have the iDevice registered to another iTunes account. Most likely you have an issue with your certificate. Make sure that in keychain under my certificates there is a triangle to the right of your developer certificate. When you click the triangle to expand it, you should see your developer key… if not (which most likely is the case) your certificate doesn’t match any keys on your keyring. Delete it and go through the certificate request again. Just make sure to update your provisions after you get the new certificate.

  15. @Mato: You lost your old keys. There is some info on the program portal on exporting your keys, however it’s too late for you ;( Just delete your certificates in keychain, request new ones, update your provisions with the new keys and you should be back in business.

  16. I submitted a binary a week ago after following Apple’s instructions for code signing. Now, I can run my app on the simulator but not on my device. In the project settings, I have set the profile to Development, not Distribution. Yet when I try to build and install it, it asks if it should install my distribution profile on my phone (which it obviously cannot do anyway). I deleted my distribution profile out of the organizer and now it won’t even build, claiming the provisioning profile can’t be found (fortunately it will still run in the simulator). I duplicated and cleaned and restarted; I haven’t found how to edit Target settings, just Project ones.

  17. Thank You!! Saved me so much time. — Needed the private keys.

  18. You absolutely rock for posting this here. Even though I’ve gone through this process a dozen times or so, using 5-6 different developer accounts, it’s amazing how many times you “just forget” that one step that makes the app refuse to board the device. Finding this page saved me hours tonight.

    You’d think I’d have written all this down myself at some point, but usually, by the time one gets the app provisioned, it’s impossible to remember to write it down. Thanks again!

  19. I absolutely HATE I mean really HATE this code signing BS!!!! It’ more confusing then making an app!! I could install my app to the iPhone just fine two days ago, today out of the blue it gave the code sign error, this isn’t the first time it happens, in the passed, I just went through the painful process to get a new profile then it worked, but not today. I spent a good four hours tried to get a new profile to no avail. This is so BS from Apple. For this I can strangle!!! who ever idoit at Apple came up with this crappy idea!!!

  20. just want to get it out of my chest. whoever created this code sing process, was he/she once a Mcrosoft engineer? he/she should be shot!!!

  21. […] How to fix iPhone Signing Errors: […]

  22. It is 4:30AM here in Texas and you have just saved my life! I have been trying to figure this out all day. As it turns out, my distribution provisioning profile was not saved in the correct folder. That solved everything.

    Thank you so much!

  23. I had the same problem,
    I’ve resolved by deleting the Distribution Profile file (.mobileprovision) from {user}/Library/MobileDevice/Provisioning Profiles/ and just copy it directly in this folder.
    It seams that installing the Provisioning Profile by dropping it on xCode Icon is causing the issue (maybe because renaming).

  24. Eventually, with xCode 3.2.3, the whole took me fifteen minutes BUT only after an entire DAY of struggling – mainly because I had no idea what I was doing.

    Thanks to your explanations above, I now understand something about the WHOLE process and also about the various pieces in xCode – so I was able to ignore those parts of the current Apple-instructions that still refer to older versions of xCode.

    Many, Many thanks!

Leave a Reply