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.

storyboarderror

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"
...
</viewController>

to:

<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"
...
</tableViewController>

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.

,

  1. #1 by Lionello Sacchi on July 9, 2013 - 4:42 am

    Same thing here, I had a Scrollview into a Viewcontroller, and this seems to generate the same problem you have.

    In DP3 this does not seem to be accepted, I have to interpone a UIView in between, but this is causing me headaches with Autolayout constraints.

    I’m very surprised about this behaviour.
    Now I’m trying to rebuild that part of the interface manually.

  2. #2 by Darren on July 19, 2013 - 5:03 am

    Great, thanks for this. I suspect the original issue for me was a bug in DP1 or DP2 as this is where the storyboard was created and even after failing to open in DP3, dropping back to DP2 allowed it to open fine.

    In my case it was a collectionViewController that was missing the ‘collection’ bit….

  3. #3 by Dan on July 30, 2013 - 2:40 am

    I’m so thankful you posted this. This is what was causing my issue to. Once I changed the viewController to tableViewController everything started working again.

  4. #4 by Sebs on August 21, 2013 - 5:56 am

    Hey thank you very much for this hint, I have been looking for a fix for quite a while until i found your blog post.

    Unbelievable that this crashes the DP3-5, but not the DP2.

    Keep up the good work!

    Cheers,
    Sebastian

  5. #5 by www.cam4.com spy cam on January 7, 2014 - 4:02 am

    I’m going to straight away grab a person’s rss when i will not to locate your own e-mail subscription url or perhaps e-newsletter service. Do you possess any kind of? Generously let me personally understand to ensure that I was able to sign up. Thanks.

(will not be published)