Contents

showTipsForTesting(_:)

Show specified tips regardless of their display rule eligibility or display frequency status for UI testing of certain tips.

Declaration

static func showTipsForTesting(_ tips: [any Tip.Type])

Parameters

  • tips:

    Array of tips to show regardless of their display rule eligibility.

Overview

This function can also be called with the launch argument -com.apple.TipKit.ShowTips FindTrailheadTip,SlopeProfileTip.

Tip statuses automatically revert back to available after invalidation when displayed using this override to enable repeat testing of presentation and dismissal.

TipKit’s display override testing functions have the following precedence:

Priority

Testing function

First

Showtipsfortesting(_:)

Second

Hidetipsfortesting(_:)

Third

Showalltipsfortesting()

Fourth

Hidealltipsfortesting()

import SwiftUI
import TipKit

@main
struct LandmarkTips: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }

    init() {
        setupTips()
    }

    // Configure tips in the app.
    func setupTips() {
        do {
            #if DEBUG
            Tips.showTipsForTesting([FindTrailheadTip.self, SlopeProfileTip.self])
            #endif

            try Tips.configure()
        }
        catch {
            print("Error initializing TipKit \(error.localizedDescription)")
        }
    }
}

See Also

Testing