How do I create a new Swift project without using Storyboards?
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
If you prefer building UIKit screens in code, you do not need storyboards at all. A storyboard-free project usually has fewer merge conflicts, a clearer startup path, and makes navigation and dependency injection easier to reason about.
What “Without Storyboards” Actually Means
A storyboard-based app normally tells iOS which storyboard to load at launch, and that storyboard creates the first view controller. A programmatic UIKit app does the same work in Swift instead:
- create a
UIWindow - create the root view controller
- assign it to the window
- make the window visible
The rest of the app can stay entirely in code.
Start with a UIKit App
If Xcode gives you a template that already avoids storyboards, that is the easiest path. If your template creates Main.storyboard, you can still convert the project cleanly.
The two main steps are:
- Remove storyboard references from the app configuration.
- Set the window and root controller yourself.
Delete Main.storyboard from the project, then remove the storyboard entry from the app configuration. In older project layouts this is often the Main storyboard file base name key. In scene-based setups, the scene manifest may also reference a storyboard.
Programmatic Launch with SceneDelegate
For scene-based UIKit apps, configure the initial window in SceneDelegate.
This is the core of a storyboard-free UIKit startup. The app now launches into HomeViewController without any Interface Builder file.
Build the First Screen in Code
Your root controller can also be fully programmatic:
This gives you a running app with no storyboard and no nib file.
If Your App Uses AppDelegate Only
Some projects, especially older ones or intentionally simplified ones, create the window in AppDelegate instead of SceneDelegate.
You use this approach when the app does not rely on scene management. The principle is the same: iOS needs a window and a root controller, and you provide both yourself.
Why Teams Prefer This Approach
Programmatic UI is not automatically better, but it has some concrete advantages:
- fewer XML merge conflicts in version control
- easier conditional layout and feature flags
- startup flow is visible in code
- reusable custom views are straightforward to compose
It also encourages you to separate view construction from navigation and business logic, which often improves testability.
A Small Navigation Example
Once your app starts in code, pushing another screen is just normal UIKit:
No storyboard segues are involved. All navigation rules stay in Swift, which many teams find easier to refactor.
Common Pitfalls
The most common mistake is deleting the storyboard file but leaving a storyboard reference in the app configuration. When that happens, the app still tries to load a non-existent storyboard and crashes at launch.
Another issue is forgetting to keep a strong reference to the window. If you create a local UIWindow and never store it, the UI may never appear.
Auto Layout problems are also common in fully programmatic screens. Every view created in code should either have a proper frame or constraints, and views using Auto Layout usually need translatesAutoresizingMaskIntoConstraints = false.
Finally, be clear about whether your project uses scenes. If you configure the window in the wrong lifecycle entry point, the app may compile but not show the expected UI.
Summary
- A storyboard-free UIKit app creates its window and root controller in code.
- Remove storyboard references from project configuration before deleting
Main.storyboard. - In scene-based apps, create the window in
SceneDelegate. - In non-scene setups, create the window in
AppDelegate. - Programmatic UI reduces storyboard coupling and keeps startup flow explicit.
Related reading
- How do I create a release build in Xcode?
- How do I create a round cornered UILabel on the iPhone?
- How do I create a transparent Activity on Android?
- How do I create a transparent Activity on Android?
- How do I create a view controller file after creating a new view controller?
- How do I create ColorStateList programmatically?
- How do I create delegates in Objective-C?
- How do I declare an array of weak references in Swift?
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.