Swift Changing the rootViewController in AppDelegate to present main or loginonboarding flow

suggest change


It is often useful to present a first-run experience to new users of your App. This could be for any number of reasons, such as prompting them to sign in (if required for your situation), explaining how to use the App, or simply informing them of new features in an update (as Notes, Photos and Music do in iOS11).


Firstly, as you are dealing with multiple flows, this is where Storyboards can be used effectively. By default your Application uses Main.storyboard for your primary flow. Your onboarding/alternative flow can be contained in a secondary storyboard, eg. Onboarding.storyboard

This has a number of advantages:

When your App launches, you can determine which flow should be presented. The logic for this can be contained in your AppDelegate:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    let isFirstRun = true // logic to determine goes here
    if isFirstRun {
    return true

In order to show the Onboarding flow, it’s worth considering how you’d like to handle the experience of dismissing it once the person using it has completed the journey, and which is semantically correct for what you are trying to create.


The two main approaches are:

  1. Swap the root view controller of the App’s main window
  2. Present the Onboarding flow as a modal journey, overlapping the Main flow.

The implementation of this should be contained in an extension to AppDelegate.

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents