There’s a really good chance that you’re working on a project that seeming begins to get larger and larger. While storyboards are great for simple applications, they can sometimes hinder your application’s more custom navigation features. A lot of times you may want to do a lot of work without Storyboards. I’ll show you easily how you can easily remove Storyboards from your projects so that you can use code for everything.

1. Removing From Project

  1. Open Info.plist for you Target
  2. Find Main storyboard file base name and remove it
  3. Delete the Main.storyboard file

2. Wrangling your AppDelegate

When you’ve created a new project, your app begins with an instance of AppDelegate.swift. By default it should look something similar to this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}


// some other methods
}

The first method is what we’re interested in. Edit it as such:

1
2
3
4
5
6
7
8
9
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.

window = UIWindow(frame: UIScreen.main.bounds)
window?.makeKeyAndVisible()
window?.rootViewController = UINavigationController(rootViewController: MyViewController())

return true
}

We are manually setting the window to the screen bounds and then the rootViewController with a navigationController with your MyViewController instance of your choice.