Archive for category Code

Figuring out iOS crashes

I was troubleshooting some iOS crashes with the team today and remembered this post I’d saved by Matthijs Hollemans, My App Crashed, Now What? It’s a great introduction for anyone starting to pick apart all the wonderful ways an iOS app – and more generally Objective-C – can break.

There’s plenty here to make me yearn for the helpful stack traces in Java once in a while (possibly the only thing I prefer about Android development…), but it’s all good stuff to know if you’re supporting a widely used iOS app in production. Enjoy!


1 Comment

Fixing Xcode 5 DP3 storyboard could not be opened / verify document content error

After updating from Xcode 5 DP2 to DP3 I found that several storyboards in my iOS project could no longer be opened, and would also prevent the project from building, with an error like:

The document “MainStoryboard_iPhone.storyboard” could not be opened. Could not verify document content.


Interestingly it did not affect several storyboards which hadn’t been touched in awhile, and for those exhibiting the problem some trial and error revealed that deleting the table view inside certain view controllers fixed it. Of course, recreating table contents with all of the layout and segue intricacies is not ideal so I poked around further using Open As Source Code and noticed that the suspect tables had become tableViews inside a viewController (versus tableViewController) which was now failing verification.

I’ve actually run into this problem before when a developer manually added a UITableView to a plain UIViewController, either by accident or because they changed their mind partway through the design, and saw unintended side effects. But in this case it seems to have started out just fine and been mangled by Xcode 5 somewhere along the way. In any case, using Open As Source Code and manually changing the involved XML tags fixes the problem, allows Xcode 5 DP3 to open the storyboard, and most importantly preserves all the content without deleting anything or disabling auto layout.

For example, change:

<viewController storyboardIdentifier="MyScreen" id="Brq-Jb-DRf" customClass="MyScreenViewController" sceneMemberID="viewController">
                    <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" allowsSelection="NO" rowHeight="70" sectionHeaderHeight="22"


<tableViewController storyboardIdentifier="MyScreen" id="Brq-Jb-DRf" customClass="MyScreenViewController" sceneMemberID="viewController">
                    <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" allowsSelection="NO" rowHeight="70" sectionHeaderHeight="22"

If you’re seeing this error without the scenario above there may be other similar problems that now fail Xcode validation which are also solved by a quick fix in the storyboard XML. I’d recommend deleting scenes or objects in the storyboard until things work, then add back a new/empty version of the object causing the problem, compare source, and if it’s a simple fix then revert and update the XML yourself similar to above.

Please comment if you find any others and I’ll add them here.



MacBook Pro Retina is as good as promised

I’ve been using a new MacBook Pro with Retina display for the past week or so and it’s by far the best Mac laptop upgrade in quite awhile. For various reasons I’ve used a whole bunch of different Mac laptops over the past few years leading up to it:

  • Pre-unibody 15″ MacBook Pro
  • 13″ unibody MacBook Pro (core 2 duo)
  • 15″ unibody MacBook Pro (i7 dual core)
  • 13″ MacBook Air (i7 dual core)
  • 15″ unibody MacBook Pro (i7 quad core)

Of these, everything up through the last 2011 MacBook Pro was not a desktop replacement. In fact, the inability to be one is what pushed me towards the MacBook Air to at least have something light and small for travel and meetings since at both work an home I had separate 27-inch iMacs for the heavy lifting. The quad-core MacBook Pro with an SSD upgrade and ability to take 16GB of RAM finally made a totally viable desktop replacement again, and became pretty much the only computer I used for the last six months. But, it was painful after having embraced the MacBook Air to be back to such a (relative) clunker. Since most of the features continuing to date the unibody design were things I had long given up using (optical drive, ethernet, firewire) I was more than ready for a slim MacBook Pro without these.

The Retina MacBook Pro was is this plus a whole bunch of display awesomeness. It’s nearly the agility of a MacBook Air with RAM, CPU, and storage that performs like a really fast desktop. But the display… well, having spent a lot of time using retina displays on the iPhone and new iPad it’s exactly the beauty you’d expect, now happily married to desktop tasks like software development. As an iOS developer, it especially stands out having Xcode and the iOS Simulator quietly render all of the Retina assets at full quality using the @2x versions just like the real device would, and working with high-res assets in Photoshop is also a joy. But even simply scrolling and reading tons of text (an inescapable part of writing code) is much easier on the eyes with the Retina display, and of course everything about the core OS just looks great with it as well.

I was also surprised by how useful the other scaled HiDPI resolutions are. Going up from the Retina default of 1440×900 (which is perfectly doubled) to 1680×1050 (the old 15″ hi-res native resolution) is quite readable and sharp, great for lots of workspace when the MBP is your only display.  Going up to 1920×1200 still stays quite clear in terms of scaling but is a touch small for my taste, and 2880×1800 – absolute native resolution, and only achievable through a third-party display utility like SwitchResX – is quite absurd, really only good for marveling at what your display is capable of and then quickly changing back to avoid a headache!

Of course I obviously don’t miss the lack of optical, ethernet, or firewire, but beyond the slim form factor and display my favorite sleeper feature has been finally having a multitude of external display ports. While single thunderbolt works well for a cinema display or iMac in target display mode, a basic side-by-side setup of multiple 1080p LCD’s (a cheap and common desktop setup) always required some imperfect solution until now: either get a display splitter that connects two displays to the single DVI connection and acts like one giant desktop across them (menu bar and dock with a monitor edge down the center? no thanks), or connecting one natively and sacracifing the other to a very mediocre and laggy DVI-over-USB connection like DisplayLink. But with the new MBP it’s possible to connect not just two but three external displays, all with full hardware-accelerated capability.

It’s worth mentioning that the flash storage is ridiculously fast as well, but having already converted to exclusive use of SSDs over the past couple years I can’t say I noticed a difference; it’s just something that finally comes standard without a ridiculous add-on price or need for a third-party drive swap anymore. Battery life seems as good as the previous MacBook Pro which is not stellar but good enough (I’m going to be charging this thing every day anyway), and other minor upgrades like better speakers and inclusion of USB 3.0 are handy but not something I use on a daily basis.

If there is one downside to the Retina display it’s probably the unavoidable glare of a glossy screen, and while it’s a huge improvement over the earlier MacBook Pro’s (and from what I can tell, also a tad better than the recent MacBook Air), side-by-side with a matte screen in front of any direct window light or unfortunate overhead fluorescent lightning it’s still quite obvious. I’m sure this would bother me more in a typical corporate office, but since I’m using it for now at a scrappy startup loft, random coffee shops, or on the couch at home it hasn’t been a problem. But on the flip side I can’t say I use the display for watching a whole bunch of movies where the glossy finish might shine either so it’s sort of a non-feature for me.

A supposed downside I keep reading about is the lack of upgradability. There were basically two things the last MacBook Pro let a user easily upgrade: the storage drive and RAM. While not user-upgradeable now, it’s a reasonably-priced BTO option to include 16GB of RAM (the most that could be upgraded with current sticks and two RAM slots anyway), and of course the built-in flash storage, while expensive, is equally fast and high quality. For a laptop I’m going to replace every 1-2 years anyway this is more than a fair trade for slender, light form factor, and having already embraced it with the MacBook Air it doesn’t bother me at all.

Overall, if a Mac is your daily laptop you will love the Retina MacBook Pro. It’s a huge upgrade and undoubtedly sets the bar for a new generation of power-user laptops led by Apple.

, ,

No Comments

MobileDay is live in the App Store!

After a couple months of hard work I’m proud to see MobileDay in the App Store! If you join or create conference calls from your iPhone check it out and share it with others. It’s a great tool for easy one-touch calling to any conference service from any meeting in your calendar and we have much more to come! You can also read more about the company and app at


No Comments

Code coverage for iOS testing with OCUnit

I recently posted steps for setting up iOS unit testing with Jenkins, but working on a new project realized I wanted to take this a step further and start seeing code coverage metrics. The configuration has evolved quite a bit but fortunately there’s a great Code Coverage with Xcode 4.2 guide from Infinite Loop that covers this and seems to work with both Xcode 4.3 and 4.4 in my testing. Be sure to check the included links, related posts, and followup in comments for troubleshooting various errors that creep up across different Xcode versions. Once tests have been run against instrumented code you can view the coverage output graphically in CoverStory on a Mac. Finally, if you want to convert this output to Cobertura-style for display in Jenkins using gcovr you’ll want to configure your Jenkins build as described in iOS Code Coverage, Cobertura and Jenkins. Good stuff!

, ,