Connect two storyboards in the same Xcode project using storyboard references

Create segues between two storyboards in the same Xcode project using storyboard references.

Naveen Sharma
3 min readJun 2, 2020

The problem with a single storyboard is that they become complex for larger projects. So It is a good practice to break a heavy/big/single storyboard to multiple storyboards. But what if we want to connect (Push/Present through Seque) a view controller from another storyboard. Here “Storyboard References” comes in rescue.
Apple introduced storyboard references in iOS 9 and macOS 10.11.
Before iOS 9, we were connecting storyboards in code by loading the storyboard and invoking instantiateInitialViewController() or instantiateViewController(withIdentifier: identifier: String)on the storyboard.

Steps to add storyboard references:

1. Create a new project with “Single View Application”.

2. Add a button to move to another view controller.

3. Add a new storyboard file and name it “SecondStoryboard.Storyboard”.

4. Now, add a new ViewController inside the “Second” storyboard and name it “SecondViewController” and set the “Storyboard ID” under the “Identity Inspector”.

5. Now Under the Main storyboard, Click on the (+) Library and search for “Storyboard Reference”.

6. Now drag and drop “Storyboard Reference” into the “Main.Storyboard”.

7. Now, in the attributes inspector of “Storyboard Reference”, select the SecondStoryboard.Storyboard from Storyboard dropdown and set the “Referenced ID” as the “Storyboard ID” of the “SecondViewController” in SecondStoryboard.Storyboard.

8. Now, create a segue from “ViewController” of “Main.Storyboard” to this Storyboard Reference and this will work as a normal segue and Push/Present a second view controller.

This is how It will work.

References:
cocoacasts.com
tutplus.com

Thank you for reading! If you liked this article, please clap to get this article seen by more people.
Please follow me on Medium by clicking Follow.
I’m also active on LinkedIn, Twitter, and GitHub.

--

--