Monday, April 7, 2014

One more gotcha

As I was writing about UIScrollView and auto layout I remembered another problem that gave me apoplectic fits last night. I had just published OttoJotts Beta 1.1 out onto TestFlightApp.com (one of the greatest resources for developers) and found a small bug. I went in, fixed the issue, recompiled and got a very strange error. I was able to build the application, create the archive (Product | Archive), and distribute it, but when I tried adding it to TestFlightApp it would prevent me saying that a required flag in the Entitlements.plist wasn't set.
This perplexed me because I had just done this not an hour earlier with no problem - why was it now beginning to give me flak? I tried thinking through what had changed - just code, I thought - and what might now be causing the problem. "Fine," I thought. "I'll add the damn flag." But I couldn't. Well, now what?
I thought the problem might have been associated with the different provisioning profiles I had set up, so I decided to clean them out. I went up on to my developer account, removed some old, expired certificates and some newer, active (but unused) certs. Then I went back to Xcode and synched my account. It looked like everything got set up properly, so I went back and tried to compile. Success. Then I tried to archive. Failure. And the failure was weird - it couldn't find a provisioning profile. I had cleaned up several and had specifically built using one profile but it was trying to find another one. What the heck was going on?
I searched the interwebs and came upon something in the Xcode project file. I think it was on stackoverflow.com that I found the solution, but I apparently needed to remove some lines from the project file that were referencing the old profile. I made my changes and tried it again - and everything was happy. Even when I put it up on TestFlightApp it went up seamlessly. Yay. *headdesk*
What's the lesson from this little excursion? Perhaps to be careful about when and where you manage your profiles. Or perhaps it's just to be a little wary of how well Xcode integrates with the developer center. I wish I could say it's a matter of reading the whole error message, but in this particular case it wasn't useful in the slightest. Good luck and happy coding.