Programmatically creating UITabBarController in Swift

Got some emails regarding how to create a UITabBarController programmatically so I’d thought I’ll show everyone as It’s pretty beneficial to know how to do it aside from doing it on Storyboard.

Step 1: Delete Main.Storyboard 😲

Yep, shocker for some newbies.

Step 2: Create UITabBarController Subclass

File -> New -> File -> Cocoa Touch Class

Step 3: Creating our Tabs

Open your UITabBarController and let’s create our tabs.

It’s pretty simple, put this in viewDidLoad()

Step 4: Update AppDelegate.swift

In AppDelegate we have to set our root view controller (our UITabBarController).

Step 5: ⌘ + R

Run your programmatically created UITabBarController!

End: Thank you as always!

I appreciate the love you guys give me, I love helping so anyone who gets stuck please don’t hesitate to ask!