An onboarding screen should appear on the first launch and never again. Save a flag when it ends, choose the first screen from that flag when the app starts, and when onboarding finishes replace the navigation stack with setViewControllers(_:animated:) instead of pushing, so Back can't return to it. The 2018 post got the replace part right; it had no "seen it" flag, so the onboarding would show on every launch. The flow below works with any onboarding screen, including Paper Onboarding.
SWIFT TIPS · UIKIT · ONBOARDING
First posted on May 29, 2018, as "Use CocoaPod Paper OnBoarding with xib file Swift 4". Rewritten on November 19, 2026. The flow was run on a Mac as a Mac Catalyst program, which runs UIKit on macOS (not an iPhone or the simulator), with Swift 6.2.3 (Xcode 26.2) on macOS 26.0.1, using an in-memory flag store instead of the real UserDefaults. Paper Onboarding wasn't installed. The code was type-checked against the iOS 26.2 SDK in Swift 5 and Swift 6 modes with iOS 15 and iOS 26.2 as deployment targets, but not run on a device.
In 2018 I built an onboarding screen with the Paper Onboarding CocoaPod and a xib. The steps: make a subclass of PaperOnboarding, set it as the class of a view in the xib, connect it as an outlet, and give it three OnboardingItemInfo pages with a title, image, description, icon, colors and fonts. A Skip button and a Daftar (sign up) button both opened the login screen with navigationController?.setViewControllers([vc], animated: true).
The library handled the animated pages. What every onboarding needs besides the pages is the decision around it: when to show it, and how to leave it for good. That part is the same with or without the library, and this rewrite tests it.
Replace the stack, don't push
The 2018 buttons replaced the navigation stack with the login screen. That's the right call, and the test shows why. Pushing the login screen on top of onboarding leaves onboarding underneath:
pushViewController(Login): stack Onboarding > Login, Back button shown: true
First launch: stack Onboarding
After Skip: stack Login, flag saved: true
Next launch: stack Login
The first line is the push version: the stack is Onboarding, then Login, so a Back button appears on the login screen and leads straight back to the intro pages. setViewControllers leaves only Login.
Show it only once
What the 2018 code didn't have is the other half: nothing recorded that onboarding was seen, so the app would start with it again on the next launch. This flow keeps the decision in one place:
import UIKit
/// Remembers whether onboarding was shown. UserDefaults in the app, a dictionary in tests.
protocol FlagStore {
func bool(forKey key: String) -> Bool
func set(_ value: Bool, forKey key: String)
}
extension UserDefaults: FlagStore {}
/// Decides the first screen and replaces the whole stack when onboarding ends,
/// so the Back button can never return to it.
@MainActor
final class AppFlow {
nonisolated static let onboardingKey = "hasSeenOnboarding.v1" // bump the suffix to show a new onboarding
let navigation: UINavigationController
private let store: FlagStore
private let makeOnboarding: (@escaping () -> Void) -> UIViewController
private let makeLogin: () -> UIViewController
init(store: FlagStore = UserDefaults.standard,
makeOnboarding: @escaping (@escaping () -> Void) -> UIViewController,
makeLogin: @escaping () -> UIViewController) {
self.store = store
self.makeOnboarding = makeOnboarding
self.makeLogin = makeLogin
navigation = UINavigationController()
}
/// Call once from the scene delegate, then make `navigation` the window's root.
func start() {
if store.bool(forKey: Self.onboardingKey) {
navigation.setViewControllers([makeLogin()], animated: false)
} else {
navigation.setViewControllers([makeOnboarding({ [weak self] in self?.finishOnboarding() })], animated: false)
}
}
/// Skip and "Sign up" both end up here.
func finishOnboarding() {
store.set(true, forKey: Self.onboardingKey)
// Replace, don't push. Animate only when the screen is visible.
navigation.setViewControllers([makeLogin()], animated: navigation.viewIfLoaded?.window != nil)
}
}
// In SceneDelegate.scene(_:willConnectTo:options:):
//
// let flow = AppFlow(makeOnboarding: { done in
// let onboarding = OnBoardingViewController()
// onboarding.onFinish = done // called by Skip and by the last page's button
// return onboarding
// }, makeLogin: { LoginViewController() })
// flow.start()
// window.rootViewController = flow.navigation
// self.flow = flow // keep a strong reference
The rest of the test above:
- First launch: the flag is missing, so the stack is just the onboarding screen.
- After Skip: the flag is saved and the stack is replaced with Login.
- Next launch: the flag is there, so the app starts on Login and never builds the onboarding screen.
How it works
- One owner.
AppFlowdecides the first screen and handles the end of onboarding. The onboarding screen only callsonFinish; it doesn't know what comes next, so the same screen works whether login, sign-up or the home screen follows. - A versioned key.
hasSeenOnboarding.v1lets you show a new onboarding after a big redesign by changing the suffix, without touching anyone's other settings. - A store you can replace. The
FlagStoreprotocol is satisfied byUserDefaultsas it is, and by a dictionary in tests, which is how this post tested the flow without writing to real settings. - Animate only when visible. My first version always animated the replacement. In the test, with no window, the animated change didn't take effect, and the stack still showed onboarding. The flow now animates only when the navigation controller's view is on screen.
- Keep the flow alive. The scene delegate keeps a strong reference to
AppFlow, as the comment at the end shows; the onboarding screen's callback holds it weakly.
The pages themselves
The pages can be Paper Onboarding, a paging scroll view, or a UIPageViewController. The onboarding post linked below builds pages that play each animation once, with no library. Whatever you use, give Skip and the last page's button the same onFinish.
A quick check for your project
- Delete the app and install it again: onboarding should appear. Launch a second time: it shouldn't.
- Finish onboarding and look for a Back button on the next screen. If there is one, the screen was pushed instead of replacing the stack.
- Search for where the onboarding flag is read. If more than one place decides whether to show onboarding, move that into one.
What the 2018 version said
The post showed creating the onboarding view controller with "Also create XIB file" ticked, and then setting the view's class to the PaperOnboarding subclass in the Identity inspector:

I left out the Identity inspector screenshot, because it showed the name of a client's app module. The page titles were in Indonesian ("Selamat Datang", "Partner Asuransi", "Daftar Sekarang!"), and the fonts came from two static properties at the end of the class, Nunito Bold and Open Sans Regular, with system fonts as fallbacks.
Keep reading on JR Devhub
Comments