Contents

0xWDG/OnboardingKit

OnboardingKit is a SwiftUI package that helps you create onboarding experiences for your app. It provides a set of views that you can use to create a welcome screen, a what's new screen, and a set of onboarding screens.

Requirements

  • Swift 5.9+ (Xcode 15+)
  • iOS 13+, macOS 10.15+

Installation

Install using Swift Package Manager

dependencies: [
    .package(url: "https://github.com/0xWDG/OnboardingKit.git", branch: "main"),
],
targets: [
    .target(name: "MyTarget", dependencies: [
        .product(name: "OnboardingKit", package: "OnboardingKit"),
    ]),
]

And import it:

import OnboardingKit

Welcome View Usage

import OnboardingKit

struct TabbarView: View {
    @State
    private var showWelcomeScreen = {
        if UserDefaults.standard.bool(forKey: "hasSeenIntroduction") {
            return false
        }

        return true
    }()

    private var features: [WelcomeCell] = [
        WelcomeCell(
            image: "star",
            title: "Welcome",
            subtitle: "To %APP_NAME%"
        )
    ]

    var body: some View {
        TabView {
          // Your tabview Code.
        }
        .sheet(isPresented: $showWelcomeScreen) {
            WelcomeScreen(show: $showWelcomeScreen, items: features) {
                UserDefaults.standard.setValue(true, forKey: "hasSeenIntroduction")
            }
        }
    }
}

What's New View Usage

import OnboardingKit

struct TabbarView: View {
    @State
    private var showWhatsNew = { // This is to show it only on a different version
        if let dictionary = Bundle.main.infoDictionary,
           let dVersion = dictionary["CFBundleShortVersionString"] as? String,
           let whatsNew = UserDefaults.standard.value(forKey: "whatsNew") as? String,
           whatsNew == dVersion {
            return false
        }

        return true
    }()

    var body: some View {
        TabView {
            // Your tabview Code.
        }
        .sheet(isPresented: $showWhatsNew) {
            WhatsNew(
                show: $showWhatsNew,
                text: "This is new!"
            ) {
                if let dictionary = Bundle.main.infoDictionary,
                   let dVersion = dictionary["CFBundleShortVersionString"] as? String {
                    UserDefaults.standard.setValue(dVersion, forKey: "whatsNew")
                }
            }
        }
    }
}

Dynamic replacements in text

| Key | Replacement | | --------------- | ----------------------------------------------------------------------------------------------- | | %DEVICE_APPS% | SF Device icon with apps name (if supported, only iPad and iPhone are supported at this moment) | | %DEVICE_TYPE% | SF Device icon name | | %APP_NAME% | The app's name | | %APP_VERSION% | The App's version number | | %APP_BUILD%" | The App's build number |

Contact

πŸ¦‹ @0xWDG 🐘 mastodon.social/@0xWDG 🐦 @0xWDG 🧡 @0xWDG 🌐 wesleydegroot.nl πŸ€– Discord

Interested learning more about Swift? Check out my blog.

Package Metadata

Repository: 0xWDG/OnboardingKit

Homepage: https://0xwdg.github.io/OnboardingKit/

Stars: 7

Forks: 0

Open issues: 0

Default branch: main

Primary language: swift

License: MIT

Topics: 0xwdg, hacktoberfest, onboarding, onboardingkit, spm, swift, swiftlang, swiftui

README: README.md