28

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.

guido
  • 2,792
  • 1
  • 21
  • 40
  • 1
    Upgrade the RAM of macbook ;) – pkc456 Oct 03 '16 at 18:05
  • @pkc456. Good tip. Thanks ;) Upgraded the macbook with an SSD and 16GB of RAM. I'm ok with it being slow, but unresponsive not OK :) Waiting for the new MacBooks to arrive :) – guido Oct 03 '16 at 18:07
  • Does it hang when working with a different project? If you use a different account, is it still a problem? – Phillip Mills Oct 03 '16 at 19:01
  • @PhillipMills Different project -> No problems. Different account -> Same problem. It's definitely my project. The Storyboard is BIG. But i had it working in Xcode 8 (although sometimes it would become unresponsive). But now it's always unresponsive and I didn't change anything. Even rolled back to a previous commit (where I know it sometimes worked). Still no luck. – guido Oct 03 '16 at 19:19
  • I reverted to a version of the storyboard that did not use container views with custom UIViewControllers and that fixed it. I don't know if it's related. – Gabriel Jensen Oct 25 '16 at 04:27
  • It's possible that you were rendering a very big image from the storyboard. That has caused me trouble here – marcelosalloum Feb 06 '19 at 22:10

16 Answers16

46

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

jscs
  • 63,694
  • 13
  • 151
  • 195
Luke Van In
  • 5,215
  • 2
  • 24
  • 45
  • 7
    You glorious individual. My CPU was running around 150% due to Xcode and a .xib. This fixed it instantly. It was still a problem when I upgraded to Xcode 8.2 – Louis Cremen Dec 14 '16 at 20:36
  • I have the same issue , When changed to "Inferred" the top bar, then it brings performance back. Thanks you help to work with some condition , but this is alternate solution, what should be exact solution ? – vnaren001 Dec 27 '16 at 06:29
  • 1
    Even just setting the top bar to inferred fixed it for me! – jhhl Dec 29 '16 at 19:45
  • 4
    If your IB is too slow for you to be able to change this, right click on the .xib/storyboard file and view it as source code. Then search for `simulatedNavigationBarMetrics` and delete the lines you find, reopen in interface build and everything should run smoothly. – Dominik Hadl Feb 19 '17 at 12:25
  • This worked for me for some reason. Now I can set that darn label! You glorious individual. – matthias_b_nz Feb 23 '17 at 20:23
  • Can't thank you enough for this. Was driving me absolutely mad! – Ben Dodson Mar 13 '17 at 13:11
  • I wish I could upvote the removal of the simulatedNavigationBarMetrics line 1 million times! Thank you! – Vee Mar 22 '17 at 21:08
  • How do you get to Simulated Metrics window? – IgorGanapolsky Mar 30 '17 at 15:09
  • I experienced the same problem on Xcode 9, and this solution works. Thanks! – zalogatomek Sep 21 '17 at 11:48
17

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>
Alex Stone
  • 46,408
  • 55
  • 231
  • 407
  • 2
    Thanks for the help. Deleting the following capability solved my problem – Abhijeet Mallick May 12 '17 at 08:08
  • 3
    Thank you very much! All of the other recommended suggestions did not work for me (I did not have simulated metrics set to opaque) but removing only the capability allowed me to open IB again and it is completely responsive again. THANK YOU!!! – pricetag Aug 09 '17 at 22:42
  • note that above lines of code is in Main.storyboard source code and to access the source code you should right click Main.storyboard and select Open As > Source Code – Hamid Reza Ansari Dec 10 '19 at 08:25
11

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/
jnic
  • 8,695
  • 3
  • 33
  • 47
7

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.

Beer Me
  • 492
  • 1
  • 7
  • 15
3

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.
Mr Lister
  • 45,515
  • 15
  • 108
  • 150
Gordon W
  • 61
  • 1
  • 6
1

Working with Xcode 8.1 beta. Guess it's a bug in Xcode 8.

guido
  • 2,792
  • 1
  • 21
  • 40
1

Until Apple fixes IB, in first XML line (<document> tag) of the offending .xib:

useTraitCollections="NO"
JBJr
  • 109
  • 2
  • 7
1

I just upgraded to Xcode 8.3 and this storyboard hanging issue came...I've tried all that mentioned above, none of them works.

Finally I noticed there's some auto-layout warning saying that one of the navigation controller scene's navigation bar size is not correct. It insists that its width should be 320 while the chosen device is iPhone 7. I switched back to Xcode 8.2.1(8.3 is just too slow to change anything!), then changed the viewing device to iPhone SE...all fixed!

Bonan
  • 709
  • 4
  • 18
1

Delete your derived data from /Users/{username}/Library/Developer/Xcode/DerivedData

(You can get exact path from) File -> Project Setting: or File -> Workspace Settings

healthycola
  • 347
  • 4
  • 9
1

I had this problem shortly after upgrading to Xcode 9, any time I changed anything in the storyboard (even moving a view by 1 px), it would hang with the spinning beachball of death for at least 10s.

I didn't want to clear my entire xcuserdata folder and lose all my breakpoints etc, but just deleting UserInterfaceState.xcuserstate and restarting Xcode worked for me.

deltacrux
  • 1,186
  • 11
  • 18
1

(Xcode 9.2) I had this happen right after I added a constraint to a stackview. No matter what I did, it didn't seem to fix it. I knew it had to be an auto-layout issue it couldn't resolve.

I ended up opening the Main.storyboard file in text editor and deleting the scene that was causing the issue. It will start with

    <!—YourViewControllerName—>
    <scene sceneID=“XXX-XXX-XXX”>

and end with </scene>. Just highlight the entire chunk, delete, save, and try again.

Much better than starting over from scratch!

wski
  • 305
  • 1
  • 10
1

I got the same problem using Xcode 9.2, fixed it by removing the stack view which wrapped up other views, I just removed the stackview and its subview tags and kept other views in the scene.

0

Here is what I did , cut the troubling viewcontroller, paste it in a new temp project's storyboard then paste back the viewcontroller. Working fine for me.

Over the time, as the storyboard grows, xcode makes a mess of keeping the history track of viewcontroller's elements and hence the freeze.

Code Tree
  • 2,160
  • 4
  • 26
  • 39
0

I've had this issue multiple times. Usually, Bonan's solution works for me. On the two occasions in which it didn't, the issue seemed to be with a toolbar bar I was using. When I isolated the offending tool bar by panning over to a place on the storyboard where the toolbar's view controller was not visible on my screen anymore, instantly the storyboard speeds back up. I then panned back to the bad view controller and deleted the toolbar before the system slowed down again. I'm sure there's a way to fix the toolbar rather than deleting it, though I don't know what that is. I had the Simulated Metrics value set to 'inferred' as described above by Luke Van In so it must have been a different problem.

Wyatt
  • 73
  • 5
0
  1. open a Finder window and navigate to your project
  2. right-click on the .xcodeproj file (it’s a package actually)
  3. select Show Package Contents
  4. a new window appears
  5. delete a folder called xcuserdata
  6. restart your mac
Naing Lin Aung
  • 3,373
  • 4
  • 31
  • 48
0

After deleting all sorts of things listed above, and restarting Xcode. The solution was to reboot the computer. Dumb I know, but somehow a resource was tied up in IB.

possen
  • 8,596
  • 2
  • 39
  • 48