iOS
Storyboard
ViewController
InterfaceBuilder
CodeMigration

Move or copy view controller from one storyboard to another

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

Moving a scene from one storyboard to another is mostly an Xcode refactoring task, not a runtime problem. The safest approach is usually to recreate or paste the scene in Interface Builder, then reconnect segues, storyboard IDs, outlets, and entry points explicitly rather than trying to depend on raw XML edits unless you are already comfortable repairing storyboard source by hand.

The Practical Options

There are three common approaches:

  • copy the scene in Interface Builder and reconnect what breaks
  • split navigation using storyboard references
  • stop relying on storyboard-to-storyboard segues and instantiate by storyboard ID in code

The best option depends on whether you want to physically move the scene or simply modularize the app.

Copying the Scene in Interface Builder

For a straightforward copy, open the source storyboard and destination storyboard, select the whole scene, copy it, and paste it into the destination storyboard canvas.

After the paste, verify all of these manually:

  • custom class on the view controller
  • module name, if relevant
  • storyboard ID
  • outlet and action connections
  • segues that used to point to scenes still located in the old storyboard

The copied visual layout usually comes across, but inter-scene wiring often needs repair.

A Better Modularization Tool: Storyboard References

If the real goal is to split a giant storyboard into smaller files, storyboard references are often better than physically moving and re-wiring everything by hand.

A storyboard reference lets one storyboard point to a scene in another storyboard while preserving storyboard-based navigation structure.

That is often the cleanest way to reduce merge conflicts and keep feature areas separate.

Instantiate from Another Storyboard in Code

If you prefer explicit control, instantiate the destination controller from its own storyboard by ID.

swift
1import UIKit
2
3final class HomeViewController: UIViewController {
4    func showSettings() {
5        let storyboard = UIStoryboard(name: "Settings", bundle: nil)
6        let controller = storyboard.instantiateViewController(withIdentifier: "SettingsViewController")
7        navigationController?.pushViewController(controller, animated: true)
8    }
9}

This works well when you want to decouple scene ownership from storyboard segues and keep feature modules separated.

To make this work, the destination scene must have its Storyboard ID set in Interface Builder.

When Raw XML Editing Is Worth It

Opening a storyboard as source code is possible, and experienced developers sometimes do it for careful moves. But it is easy to break scene identifiers, relationship links, or object references if you are not already comfortable with storyboard XML structure.

So XML editing is a repair tool or power-user technique, not the first recommendation for most teams.

If you use it, keep the scope tight:

  • move one scene at a time
  • save a backup first
  • reopen in Interface Builder immediately to catch structural errors

Things That Commonly Break After the Move

The most common breakage points are not the view hierarchy itself. They are the references around it.

For example:

  • segues pointing to scenes still in the old storyboard
  • initial view controller settings
  • embed relationships such as navigation or tab controllers
  • runtime identifiers used by code
  • outlets to objects that were storyboard-local rather than scene-local

That is why testing after the move is mandatory, even if Xcode shows no obvious syntax problem.

Common Pitfalls

Assuming copy-paste moves every segue cleanly is the most common mistake. Cross-scene references often need manual repair.

Editing storyboard XML without understanding object IDs and references can corrupt the file quickly.

Forgetting to set or preserve the storyboard ID breaks programmatic instantiation later.

Finally, if the main goal is only to split a massive storyboard, storyboard references are often simpler than physically moving everything and recreating navigation wiring from scratch.

Summary

  • copy-paste in Interface Builder is the normal way to move a scene, but it requires follow-up verification
  • storyboard references are often the best way to modularize a large storyboard-based app
  • programmatic instantiation by storyboard ID gives explicit control across storyboard boundaries
  • raw XML editing is possible but risky unless you already understand storyboard source structure well
  • after any move, verify segues, outlets, identifiers, and navigation behavior manually

Course illustration
Course illustration

All Rights Reserved.