Apple iPhone Provisioning Hell: have you tried restarting XCode?

I just spent way too long trying to get my iPhone app transferred to my phone for testing.

To Apple's credit, their web site is very logically laid out and takes you through the numerous hoops you have to jump through quite well. Unfortunately, after setting up my team, creating my certificates, registering my device, setting up an App ID (hint: use * for your Development Provisioning Profile so that you can use any bundle identifier with it), downloading my provisioning profile and, finally, installing it XCode and syncing it to my iPhone, I got the following error while trying to build and deploy to my iPhone:

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

I then proceeded to twiddle with everything I could possibly think of and started Googling like a mad man and twiddling with things that the pages I found told me to twiddle with. Unfortunately, of this twiddling produced any results.

In the end, what fixed it was restarting Xcode.

I only tried it after reading a comment on this post. Mr "v", whomever, you are, thank you!

After restarting, my build completed successfully, but, this time, it wouldn't deploy to the phone. My new error was:

The the device doesn't have provisioning profile the application was signed with.

During my twiddling, I had created a second provisioning profile, deleted the first one, and transferred the second one to my phone. Even though the first provisioning profile did not exist either in the Organizer in XCode or on the phone, I was getting this error. Thinking that a similar sort of caching must be at play, I proceeded to do the following:

  1. Delete both the provisioning profiles under ~/Library/MobileDevice/Provisioning Profiles (interestingly, they were both there, even though I had removed the other one from the organizer in XCode)
  2. Restart XCode

And that did it. To tell you the truth, I don't even know if Step 1 was necessary. It may just be that XCode was caching something and the restart did the trick yet again.

So, all this to say, if you're in iPhone Provisioning Hell, you may want to try restarting XCode first, before pulling out your hair.

Comments