OnboardingKit Documentation

repository·main·Indexed 22 days ago

https://github.com/danielsaidi/onboardingkit

A SwiftUI SDK for creating diverse onboarding experiences across Apple platforms. It provides onboarding types for conditional, delayed, and corrective behaviors, along with UI components like OnboardingPageView, OnboardingSlideshow, and OnboardingIntroScreen. The kit also includes the String Catalog Public Key Builder and l10n-gen command-line tool for generating public key wrappers for Xcode string catalogs.

Tokens
1.4K
Snippets
2
Records
11
Agent score
78%

What's inside OnboardingKit

  1. Overview of OnboardingKit components

    main

    OnboardingKit is a SwiftUI SDK designed for creating onboarding experiences across all major Apple platforms. The library is organized into several functional categories:

    • Essentials: Core abstractions like Onboarding, OnboardingPage, and OnboardingUsp.
    • Flows: Logic and container management via OnboardingFlow, OnboardingFlowContainer, OnboardingFlowCenteredContent, and OnboardingFlowState.
    • Pages: Page-based layouts using OnboardingPageView and OnboardingPageViewStyle.
    • Slideshows: Sequence-based experiences using OnboardingSlideshow, OnboardingSlideshowConfiguration, OnboardingSlideshowProgressView, and OnboardingSlideshowStyle.
    • Views: Reusable UI components such as OnboardingIntroScreen, OnboardingPrimaryButton, and OnboardingUspListItem.
  2. Generate public key wrappers with String Catalog Public Key Builder

    main

    The String Catalog Public Key Builder is a command-line tool designed to generate public key wrappers for internal, auto-generated keys within an Xcode string catalog.

    By default, Xcode-generated keys are internal to their target and cannot be accessed from other targets. This tool creates public wrappers that use the .module bundle, ensuring strings are properly localized regardless of which target calls them. It also supports hierarchical namespaces to group strings and prevent collisions.

  3. Apply namespaces to string keys

    main

    To group strings together and reduce merge conflicts, you can use dot-notation in your keys to create a nested hierarchy.

    For example, a key named Experiments.DebugScreen.Title will be transformed into the following public key format: .l10n.experiments.debugScreen.title

    Additionally, you can customize the l10n root namespace name. This is useful when parsing multiple different string catalogs to prevent generated keys from colliding.

  4. Use Onboarding view components and flows

    main

    The SDK provides several specialized view components to handle different types of onboarding flows and page state management:

    • OnboardingPageView: Best for presenting pages that the user scrolls through manually.
    • OnboardingSlideshow: Best for presenting an automatically progressing slideshow.
    • OnboardingIntroScreen: Used to present a welcome screen specifically on the first app launch.
    • OnboardingScreen: A wrapper component that can be used to encapsulate any onboarding flow.
  5. Understand Onboarding types and behaviors

    main

    OnboardingKit uses different Onboarding types to define when and how an onboarding experience is presented to the user. Choosing the right type allows you to tailor the onboarding behavior to specific user scenarios:

    • Onboarding: Presented immediately and only once.
    • Onboarding.Conditional: Presented only when a specific condition evaluates to true.
    • Onboarding.CorrectBehavior: Presented when the system detects the user is not behaving as intended.
    • Onboarding.Delayed: Presented after a specific number of presentation attempts has been reached.
  6. How Onboarding types determine behavior

    main

    In OnboardingKit, an Onboarding object defines the logic for when and how often an onboarding experience should be shown to the user. Instead of manually managing state, you choose a type based on the desired behavior:

    • Onboarding: Presented immediately and only once.
    • Onboarding.Onboarding/Conditional: Presented only when a specific condition evaluates to true.
    • Onboarding.Onboarding/CorrectBehavior: Presented when the user's behavior deviates from the intended pattern.
    • Onboarding.Onboarding/Delayed: Presented only after a specific number of presentation attempts has been reached.

    You can also create custom behaviors by inheriting from these classes and overriding their functions.

  7. Use OnboardingKit views and components

    main

    OnboardingKit provides several layers of UI components:

    Flow Views

    Used for managing sequences of screens:

    • OnboardingPageView
    • OnboardingSlideshow

    Screen Templates

    Pre-built layouts for onboarding steps:

    • OnboardingIntroScreen

    Small Components

    Atomic UI elements that can be used within larger views:

    • OnboardingPrimaryButton
    • OnboardingVerticalProgressList

    Styling

    Components are highly customizable. For example, you can apply custom styling to an OnboardingPageView using the .onboardingPageViewStyle(_:) modifier.

  8. Use the l10n-gen command-line tool

    main

    You can use the l10n-gen tool to generate keys in two ways:

    1. From a specific catalog: Parse a from catalog and write the resulting keys to a to target file path.
    2. From a package module: Parse any package module string catalog at a package-relative catalogPath and write it to a package-relative targetPath.

    To see all available flags and usage examples, run:

    swift run l10n-gen --help

    For convenience, you can also use the provided script:

    /scripts/l10n-gen.script
  9. Install OnboardingKit via Swift Package Manager

    main

    You can add OnboardingKit to your Xcode project using the Swift Package Manager (SPM). Use the following repository URL during the package dependency addition process:

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