Simplify usage of storyboard & nib files
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Interface Backed

Carthage compatible

Original idea and implementation by Benjamin Sandofsky's gist

I just simplified the code a bit and put it in a Framework. Added a similar approach for UIView subclasses that rely on a .nib file.

Released under the MIT license


Your classes must be declared final to adopt the protocol.


final class ViewController: UIViewController, StoryboardBacked {}

let vc = ViewController.newFromStoryboard()

You can use a custom name or a custom bundle. The function defaults to a storyboard named as the view controller and to the bundle the class is in. So this works even when your view controller class in inside a framework and not the main bundle.

Hint: Double check that you made your custom view controller the initial view controller for the storyboard.


final class Cell: UITableViewCell, NibBackedCell {}

tableView.registerNib(Cell.cellNib(), forCellReuseIdentifier: Cell.identifier())

Hint: Double check the identifier for the cell in the .nib file. It must reflect the name of the class.

For more information check the included Example target.