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.

Autolayout and UIScrollView

Just a quick update on a small problem I uncovered. I was working on OttoJotts last night trying to get Beta 1.1 out the door (I did eventually get it out, although it was Beta 1.11) when I stumbled on a problem with the UIScrollView I'm using for the help file. When I created the first Beta 1.0 I ran into an issue with the buttons not working on 4 inch screens (I originally wrote the app for iPhone 3G to give you an idea of how long this has been). I went through all of my xib's in Interface Builder and updated them to use auto layout and - ta da! - everything worked. Except for help.
My help screen has two elements - a UIButton to close the help screen and a UIScrollView to view the incredibly long png I created for the help (it's over 2k pixels in length). When using auto layout with a UIScrollView, the scroll view interprets the setting meaning a slightly different experience than what you'd expect. When I turned off auto layout, the scroll view worked perfectly well and I was able to view all of the help text correctly - with one exception: the UIScrollView was now positioned at the bottom of the interface rather than directly under the button.
I still have some things to work out with the 3.5" and 4" screens so I'm holding off on fixing that until a later date. Still, it's something to keep in mind - UIScrollView and auto layout are not good buddies.