Sunday, July 12, 2009

CodeSigning Hell

The best advice I can give to anyone who wants to develop iPhone applications is: When you get an error, READ THE ENTIRE ERROR MESSAGE VERY CAREFULLY. Here endeth the lesson.
I had decided to update my code signing certificates for the alpha that will be starting in the not-too-distant future. I also wanted to try to get it building for distribution on OS 2.2 devices because one of my testers is on an iPod Touch that costs $10 to upgrade to 3.0. Eventually I will need to move completely to 3.0 to get the in-app purchasing I require, but for now, compatibility is a good thing.
I made some new certs, read the instructions carefully on the Apple Dev Portal and things were going along smoothly. I had a bit of a hitch when I forgot to copy in the distribution and developer certificates to Xcode, but that wasn't too heinous. Then I tried building for 2.2. Error. And something that seemed completely odd. CodeSigning was complaining that I hadn't provided a certificate for 'Distribution' for SDK 'Device - OS 2.2'. Um, sure. Not terribly helpful. Can I build OS 3 builds? Yes - no problem. OS 2.2? No. I checked the build settings - yup, there's my certificate, it's setup for all iPhone Devices... What's your damage, Xcode? Okay, fine. You win. I'll ADD a special exception for OS 2.2. Bzzzt! Still not happy. What the HELL, man? C'mon, give me SOMETHING.
*sigh* After beating my head against it for a while, I went back and looked at the steps. Yes, I did that. And that. And thanks for the warning about making sure I did that - I did. Okay, let's Google it. I have to completely reset my Xcode to make it happy? I'm not sure that's the right answer.
Okay, one last time. Let's close Xcode, reopen, and try building it again. Nope. As expected, the same error. But wait. What does that error really say? Seriously? What configuration am I editing in the properties? DEBUG?!?! And it needs to be DISTRIBUTION?!?!?! *sigh* *facepalm*
So, let's make sure we're editing the configuration for Distribution and attach the certificate for all iPhone devices. Okay, Xcode, let's see if that makes you happy. And it does. And had I bothered to read the error message and double-check to make sure that I was actually editing the correct properties, life would have been better. But, thankfully, now it is.
Here endeth the lesson.