Skip to content

OnboardingKit helps you create onboarding experiences in Swift and SwiftUI.

License

Notifications You must be signed in to change notification settings

ferencIOS/OnboardingKit

 
 

Repository files navigation

OnboardingKit Logo

Version Swift 5.9 MIT License Twitter: @danielsaidi Mastodon: @danielsaidi@mastodon.social

About OnboardingKit

OnboardingKit helps you create onboarding expericences like hints and tutorials in Swift and SwiftUI.

The result can look like this, or completely different:

OnboardingKit has different onboarding types. Standard onboardings are shown right away, and only once, while other types can require multiple presentation attempts, a certain number of "incorrect" actions, etc. You can also combine different onboarding types to create new ones and reset the state of any onboarding to display it again.

OnboardingKit supports multiple users, so that each onboarding is unique to each user.

Installation

OnboardingKit can be installed with the Swift Package Manager:

https://github.com/danielsaidi/OnboardingKit.git

If you prefer to no have external dependencies, you can also just copy the source code into your app.

Getting started

In OnboardingKit, an Onboarding determines the state and behavior of an onboarding experience, while a Hint is a short onboarding message and a Tutorial is a page-based onboarding flow.

You can use various Onboarding types to get different behaviors.

The code below shows how to use a standard onboarding to present a hint or tutorial:

import OnboardingKit
import SwiftUI

struct ContentView: View {

    @State
    private var isOnboardingPresented: Bool 
    
    private let hint = Hint(title: "Welcome!", text: "Welcome to this app.")
    private let tutorial = LocalizedTutorial(id: "welcome")

    var body: some View {
        Text("Hello, world")
            .onAppear(tryPresentOnboarding)
            .sheet(isPresented: $isOnboardingPresented) {
                TutorialPageView(tutorial: tutorial)
            }
    }
    
    func tryPresentOnboarding() {
        let onboarding = Onboarding(id: "welcome")
        onboarding.tryPresent { 
            // Present the hint, for instance in a toast or a callout
            // ...or, present the tutorial
            isOnboardingPresented = true
            // ...or do anything you want
        }
    }
}

As you can see in the code above, the onboarding holds the state and behavior, while the presentation block defines what should happen.

For more information, please see the online documentation and getting started guide.

Documentation

The online documentation has more information, code examples, etc.

Demo Application

The demo app lets you explore the library on iOS and macOS. To try it out, just open and run the Demo project.

Support my work

You can sponsor me on GitHub Sponsors or reach out for paid support, to help support my open-source projects.

Contact

Feel free to reach out if you have questions or if you want to contribute in any way:

License

OnboardingKit is available under the MIT license. See the LICENSE file for more info.

About

OnboardingKit helps you create onboarding experiences in Swift and SwiftUI.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 96.1%
  • Ruby 3.9%