I'm trying to implement a complex rule to display a Tip from TipKit.
I'm using the official documentation (https://developer.apple.com/documentation/tipkit/tips/event) as example. But the same exact code doesn't compile and gives me the error "The filter function is not supported in this rule." on the line $0.donations.filter { $0.landmarkName != "Wilbere Bowl" }.count > 3
import SwiftUI
import TipKit
struct ContentView: View {
var tip = InlineTip()
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
TipView(tip)
Button("TIP") {
InlineTip.didViewLandmarkDetail.sendDonation(.init(landmarkID: 0, landmarkName: "TEST"))
}
}
.padding()
}
}
struct InlineTip: Tip {
static let didViewLandmarkDetail = Tips.Event<DidViewLandmark>(id: "didViewLandmarkDetail")
var title: Text {
Text("Save as a Favorite")
}
var message: Text? {
Text("Your favorite backyards always appear at the top of the list.")
}
var image: Image? {
Image(systemName: "star")
}
var rules: [Rule] {
// Define a rule based on the interaction.
#Rule(Self.didViewLandmarkDetail) {
$0.donations.filter { $0.landmarkName != "Wilbere Bowl" }.count > 3
}
}
}
struct DidViewLandmark: Codable, Sendable {
let landmarkID: Int
let landmarkName: String
}
Sorry, if it's a duplicate. I couldn't find anything related to this error.