35

I'm helping someone out with an xcode project but it's almost impossible. They have around 100 View controllers on their storyboard and it's just running really slow. I've followed all of the guides on making Xcode faster but they just don't help for this situation. Outside of that storyboard, when we're working in the .h and .m files it runs perfectly fine, it's just inside the storyboard that it runs slow. Has anyone had any experience with a project like this? What did you do? Or what can I do to make it possible to work in the storyboard? Thanks

1
  • Apple actually never said "use one storyboard for everything". A xib represents a view, a storyboard represents one or more view controllers. They needed to represent the whole controller, not just its view. I mostly use storyboards with 1-3 controllers, representing one data flow. Also I heavily use nested controllers (content containers) and storyboard references. Even if storyboards with 10+ controllers were faster, it still wouldn't be a good idea to use them.
    – Sulthan
    Nov 14, 2018 at 10:28

7 Answers 7

49

My solution is: Open a new Window from the Storyboard and minimize it. So it stays in RAM and won't reload. Working with the storyboard keeps quick and easy now.

2
  • This is perfect! I had just one view controller which was excessively heavy! Thanks! May 10, 2016 at 10:53
  • 1
    Double click the storyboard.
    – Nianliang
    Dec 27, 2016 at 5:12
42

I faced the same issue when I was working on an Enterprise App. In the Project I had only one storyboard and all views in a single storyboard. Opening the storyboard caused Xcode to get very slow.

So I divided the storyboard into multiple storyboards as module-wise and load a separate storyboard per module like in the code below:

If I want to push a view controller:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"storyboardName" 
                                                     bundle:nil];
UIViewController *viewController = 
 [storyboard instantiateViewControllerWithIdentifier:@"Members_ViewController"];

[self.navigationController pushViewController:viewController animated:YES];
7
  • 2
    The app has 4 tabs, do you think we should make 4 storyboards? (one for each tab)?
    – BrownEye
    Sep 10, 2013 at 5:45
  • 1
    yes why not and at the tab define you can Load separated storyboards as i mention. There are no any restication for crating multiples storyboards Sep 10, 2013 at 5:47
  • So do I make the segue link to a view controller in a different storyboard?
    – BrownEye
    Sep 10, 2013 at 6:17
  • Nope you doing woth code as we did early without story Board do not connect view segue link from stoaryBoard bcz we are difine instance or particular viewcontroller from storyboard programeticuly instantiateViewControllerWithIdentifier Sep 10, 2013 at 6:19
  • 9
    If you need to segue from one view controller to another, they have to be in the same storyboard. That is why, if you have multiple storyboards, each one should represent one major path (or "story") in your app. For instance, if you have a tab-driven app with 4 tabs, where each tab has a navigation controller hierarchy, you could have 4 storyboards, one for each tab. When you setup the UITabBarController, you would have to instantiate the root view controller of each tab using UIStoryboard *tab1SB = [UIStoryboard storyboardWithName:@"foo" bundle:nil] etc..
    – Eric G
    Oct 11, 2013 at 1:34
8

We're having the same issue, and commonly recommended performance tweaks didn't help. On a MacBook Pro with SSD I see CPU utilization go to 80-90% when in storyboard view and navigation lag is incredibly frustrating. Simulator can take up to a minute to display, and Xcode often won't close, requiring a force quit.

These symptoms all disappear if not viewing the storyboard, or if storyboard is open as source code.

UPDATE: We split our project up into multiple storyboards, and life is good again - CPU utilization is back to single digits and performance is on par with Xcode 4.6.3. There is definitely an issue with larger storyboards; the only change made to our code in the process was updating references to the main storyboard to a storyboardWithName call instead.

One of the view controllers in our project has a container view, and it appeared that the utilization issue stopped when that controller and its container view were moved to a separate storyboard. It may have been a coincidence, and we broke up the rest of the storyboard for consistency, but if I were dealing with this issue again, I'd first move any view controllers with container views to a separate storyboard.

3
  • 1
    Each storyboard is a (potentially huge) XML document that is parsed and displayed as a GUI when viewed. Maybe the performance dip between Xcode 4 -> 5 in Storyboard is because some caching/optimization was lost, but more likely because the Storyboards got a lot more intelligent in Xcode 5. The interface can check for and resolve constraint issues in real time, for instance.
    – Eric G
    Oct 11, 2013 at 1:36
  • How many screens were in your storyboard, for curiosity? Would be good to get a rough sense at what limit storyboards need to be broken down at.
    – Marchy
    May 30, 2014 at 17:54
  • I had 4 screens in a storyboard with < 50 objects total and it was a 6-7 second lag every click, sometimes more. The answer was the container view. As soon as i removed that it instantly went to smooth performance. Mar 20, 2016 at 21:16
8

If you are using Xcode 7, Storyboard References are a quick way to create multiple storyboards and will definitely help this issue. The great side about using Storyboard References is it does not involve any extra code whatsoever! See the stackoverflow link below for a full description on how to set it up.

enter image description here https://stackoverflow.com/a/30772789/3316842

2

I'm facing the same problem. Massively frustrating. My storyboard has only 41 views. And I'm running a Mac Min i7 running at 2.3Ghz. With the storyboard open, it takes ages to do very simple tasks like move a UILABEL? Then, in counterpart view, editing code is like being back on a ZX81. It's all very well and good banging "intelligence" into the storyboard, but not at the cost of development efficiency. In so far as storyboard "size" guidelines are concerned, I don't ever remember reading that storyboards have to be split beyond a certain size. Maybe I need to read more.

To make the changes required, i.e. split the storyboard up, slap some VC's on several storyboards, will require a bit of a faff. I suppose if that's the new best-practice, fine. But I could do with more than conjecture.

0
1

I also agree with organizing your views across multiple story boards. It becomes very handy when you have a view that is called from several other views. Then the storyboard can become like pasta, unclear. In my case I had a camera view that could be called from several views, I put this on a new storyboard and this works great. Since the camera view was also pointing to the search order view, I had to put the search order view also on a separate storyboard. Again my main story board got simpler.

So have a main story board, and separate as much as you can onto separate storyboards. I made a general class StoryBoardNavigation where I centralized all functions to call child storyboards.

Here is an example of this:

This function navigates to the storyboard called OrderLookupStoryboard and opens the view in start position.

+(void) NavigateToOrderLookupFrom:(UIViewController *)vc
{
    UIStoryboard * sb = [UIStoryboard storyboardWithName:@"OrderLookupStoryboard" bundle:nil];
    UIViewController * vcTo = [sb instantiateInitialViewController];

    [UIView transitionWithView:vc.view duration:0.8     options:UIViewAnimationOptionTransitionCrossDissolve
                animations:^{
                    [vc.navigationController pushViewController:vcTo animated:NO];
                }
                completion:NULL];

}

This function passes some parameters to the storyboard.

+(void) NavigateToCameraFrom:(UIViewController *)vc WithSelectedZone:(int)selectedZone
{
    UIStoryboard * sb = [UIStoryboard storyboardWithName:@"CameraStoryboard" bundle:nil];
    MediaCapture * vcTo = [sb instantiateInitialViewController];
    vcTo.selectedZone = selectedZone;
    vcTo.zoneSet = YES;
    [UIView transitionWithView:vc.view duration:0.8 options:UIViewAnimationOptionTransitionCrossDissolve
                animations:^{
                    [vc.navigationController pushViewController:vcTo animated:NO];
                }
                completion:NULL];

}

This function opens the view in module transition style:

+(void) NavigateToSignatureFrom:(UIViewController *)vc withSignee:(NSString *) Signee
{
   UIStoryboard * sb = [UIStoryboard storyboardWithName:@"SignatureStoryboard" bundle:nil];
   UIViewController * vcTo = [sb instantiateInitialViewController];

   ((SignatureVC *) vcTo).Signee = Signee;

   [vcTo setModalTransitionStyle:UIModalTransitionStylePartialCurl];
   [vc presentViewController:vcTo animated:YES completion:nil];
}
-2

I wanted to add that I was having a problem with my storyboard responding slowly when utilizing a container view with a navigation controller inside it. I even tried putting it in its own storyboard and it still was so slow i was unable to even use it. It seems that the when container view was resizes the navigation controller, the navigation bar was causing the issue.

I was able to work around this problem by selecting the navigation controller in the storyboard, hiding the navigation bar by unchecking "shows navigation bar" in the attributes inspector and using "isNavigationBarHidden = false" in either viewDidLoad or viewWillAppear of my view controller class.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.