Xcode 8 hangs / unresponsive when opening storyboard

14,183

Solution 1

In my experience, for an old project, opening with XCode8, it urgently wants to ask you some question about default device to view storyboard with. This question is so critical that until you answer it, you are staring at an invisible dialog window until XCode becomes unresponsive.

A couple solutions worked for me:

  1. If you get a 1.5 second window of responsiveness when starting XCode - immediately switch to a non-storyboard file. If working with a split pane editor with the storyboard in auxilary panel, toggle it off.
  2. Create another storyboard, open it, XCode will ask you the question about default device.
  3. Answer the question, save the project state and hope to open the storyboard

Deleting these capabilities allowed me to re-open the storyboard

    <capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
    <capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
    <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>

Solution 2

I came across the same problem with one nib in Xcode 8.1.

Having "Top Bar" and/or "Bottom Bar" set to anything but "Inferred" caused Xcode to slow down to a crawl. Changing this to "Inferred" brings performance back to normal, with the downside that it removes the bars in the preview.

Incorrect settings

Correct settings

Solution 3

I had a similar problem: Interface Builder was slow to the point of being almost completely unresponsive.

I found that clearing my xcuserdata directory restored IB to normal speed.

Presumably some bad state had crept in that was causing the slowdown.

rm -rf Project.xcodeproj/xcuserdata/
rm -rf Project.xcworkspace/xcuserdata/

Solution 4

I finally figured out a fix, based in large part on the answers to this question. It finally came down to a stare-and-compare with the XML of a working storyboard, but here's a summary of the steps I took.

  • Reinstall Xcode 8.2.1 and reboot

  • Remove config, state, and data files

    rm -rf ~/Library/Developer/*
    rm -rf ~/Library/Caches/com.apple.dt.Xcode/*
    rm -rf ~/Library/Developer/Xcode/DerivedData/*
    rm -rf ApplicationName.xcodeproj/xcuserdata/
    rm -rf ApplicationName.xcworkspace/xcuserdata/
    rm -rf ~/Library/Saved\ Application\ State/com.apple.dt.Xcode.savedState/
    
  • Fix autolayout issues

  • Remove all dependencies from storyboard XML except:

    <dependencies>
        <deployment identifier="iOS"/>
        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
    </dependencies>
    
  • Check all storyboards and xib files, ensuring that all "Top Bar" and "Bottom Bar" are set to "Inferred"

The last two items seemed to be the most important.

Solution 5

How I solve the storyboard hanging issue:

  1. Back up the problematic storyboard file.
  2. Delete it in the project.
  3. Create a new storyboard with the same name and location as the deleted one.
  4. Edit the 2 storyboards with text editor.
  5. Copy the xml data after the </dependencies> tag from the old one to the new one.
Share:
14,183
guido
Author by

guido

Indie iOS App Developer

Updated on June 17, 2022

Comments

  • guido
    guido about 2 years

    I've recently upgraded to Xcode 8 and updated my project to Swift 3. All worked fine for a little while. Storyboard loading has always been slow (even when still running Xcode 7) and was about the same 'slow' with Xcode 8. I always imagined this is because I'm on a older (late 2011) Macbook Pro.

    But recently sometimes Xcode would just hang when I tried to open the storyboard. And since yesterday it's ALWAYS 'hanging'. Xcode becomes unresponsive and I have to Force Quit it.

    In Activity Monitor I see Xcode using 102% CPU and Memory usage just keeps on growing (over 10GB if I let it).

    Now I'm really stuck because when I open Xcode it immediately opens my project and wants to open the storyboard. I can't even change to a swift file. I'm not getting the window where I choose my project anymore. So, can't open my project anymore without Xcode turning unresponsive. Even when I double click another project to open Xcode it still tries to open my project (on the storyboard).

    I've tried a number of things (based on SO threads I could find on similar problems with older versions of Xcode):

    • Removed Xcode and removed contents of ˜/Library/Developer. Then reinstalled Xcode.
    • Removed contents of var/folders
    • Removed contents of derived data folder
    • Restart Macbook

    My next try is going to be to download the Xcode 8.1 beta. But really rather not do that.

    Any other suggestions on things I could try?

    SMALL UPDATE: Managed to clear the 'state' of Xcode where it opens my project by default and also opens it on the storyboard. Did this by:

    • Removing the ~/Library/Saved Application State/com.apple.dt.Xcode.savedState folder (this will show the recent project window again on startup)
    • To also prevent the project from loading a specific file upon opening I went to the contents of .xcworkspace (in my project folder) and then removed /xcuserdata/myusername.xcuserdatad/UserInterfaceState.xcuserstate. Now the project opened without any file selected.

    Still... the main problem remains. When I click on my storyboard Xcode becomes unresponsive.