How to create segues between different storyboards in the same Xcode project using storyboard references| iOS?

This article explains how we can create segues between multiple storyboards in the same Xcode project using storyboard references.

an image
an image

The problem with a single storyboard is that they become complex for larger projects. It is also difficult to maintain and also the source control part becomes a headache as well. Storyboard references are going to be helpful when you want to divide your views betweens storyboards and avoid all these issues.

How to use storyboard references?

  • Create a new project (Single view application).
  • Create a new storyboard file and name it Second.storyboard .
Image for post
Image for post
  • Now, create a new ViewController inside the Second storyboard and name it SecondViewController .
Main storyboard and FirstViewController
Main storyboard and FirstViewController
Main storyboard and FirstViewController
Image for post
Image for post
Second storyboard and SecondViewController

Now Click on the (+) Library and search for Storyboard Reference.

Image for post
Image for post

Now drag and drop Storyboard Reference into the Main.StoryBoard . Now, in the attributes inspector, select the Second.Storyboard from Storyboard dropdown and set the Reference ID as the Storyboard ID of the SecondViewController in Second.StoryBoard .

Image for post
Image for post

And now, we can create a segue from FirstViewController to this Storyboard reference for Second.Storyboard and this will work as a normal segue. Here, I have added a UIButton in FirstViewController and added a Segue to the storyboard reference.

an image
an image

That’s it. It simply works!!!

Image for post
Image for post

Note: Storyboard references were introduced in iOS 9 and macOS 10.11.

References:

If you enjoyed reading this post, please share and give some claps so others can find it 👏👏👏👏👏 !!!!

You can follow me on Medium for fresh articles. Also, connect with me on LinkedIn.

If you have any comment, question, or recommendation, feel free to post them in the comment section below!

Written by

iOS and tvOS developer, dreamer, photographer 🤨

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store