TipKit popover inside ForEach Loop

I've encountered a problem when placing a tip on an element in a ForEach loop. As long as there is only one element in the list the tip will be shown. But if there are more than one element the tip does not appear on iOS and iPadOS.

How do I get the tip to be displayed when several elements are displayed? Is it allowed to use the popoverTip() modifier in a ForEach loop or should it be avoided?

Interestingly, it works if you run the attached sample code on macOS. Then the tip is displayed on the “Third” element.

import SwiftUI
import TipKit

struct ContentView: View {
    private var elements: [String] = ["First", "Second", "Third"]

    let tip = DemoTip()

    var body: some View {
        NavigationStack {
            List {
                Section {
                    ForEach(elements, id: \.self) { element in
                        Text(element)
                            .popoverTip(tip)
                    }
                }
            }
        }
    }
}

struct DemoTip: Tip {
    var title: Text {
        Text("Demo Tip")
    }
}

@main
struct TipKitTestApp: App {
    init() {
        #if DEBUG
            Tips.showAllTipsForTesting()
        #endif

        try? Tips.configure([.displayFrequency(.immediate)])
    }

    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

Seems like you're trying to present all the tips in your child views at once which would be an issue.

You might to specific some rules or events that trigger the particular tip in your collection. Checkout Highlighting app features with TipKit sample code, specifically FoodDetailView.swift source file for an example.

Thank you very much, that example is exactly my scenario, what I want to implement, but even in the sample code I ran into the same problem. As long as there is more than one FoodEventTip.Item in the list, the tip is not shown.

Based on the rules, the tip should be displayed with the fifth favorite, but it is not.

More than one item, no tip will be shown:

Array has only one item, the tip will be shown:

Also, if you move the popoverTip view modifier onto the HStack it will be shown, but then it's not on the button. Seems that there is some bug with popoverTip inside a ForEach loop.

Xcode Version 16.4 (16F6) and iPad Simulator with iPadOS 18.5

@Lars_ Could you please file a bug report and post that here. Once you do, I'll follow up with the engineering team on that.

TipKit popover inside ForEach Loop
 
 
Q