TipKit: How to support `concurrency-safe`

When I build app on Xcode 15.3 with SWIFT_STRICT_CONCURRENCY=complete, there are some warning.

Almost warning can be fixed, but not the TipKit code.

Here is the example.

Are there any good way to solve it?

Answered by yomo in 787763022
@MainActor
struct SomeTip: Tip {
    @Parameter
    static var haveSome: Bool = false
    
    static let eventOneHappened = Event(id: "eventOneHappened")
    
    nonisolated var title: Text {
        MainActor.assumeIsolated {
            Text("***")
        }
    }
    
    nonisolated var image: Image? {
        MainActor.assumeIsolated {
            Image(systemName: "heart")
        }
    }
    
    nonisolated var options: [TipOption] {
        MainActor.assumeIsolated {
            [Tip.MaxDisplayCount(1)]
        }
    }
    nonisolated var rules: [Rule] {
        MainActor.assumeIsolated {
            [
                #Rule(Self.$haveSome) { $0 == true },
                #Rule(Self.eventOneHappened) { $0.donations.count >= 1 }
            ]
        }
        
    }
}

I wrote it like this at the beginning. Although there is no warning now, it looks strange. However, my rules are pretty simple, all it takes is control through Event.

Accepted Answer
@MainActor
struct SomeTip: Tip {
    @Parameter
    static var haveSome: Bool = false
    
    static let eventOneHappened = Event(id: "eventOneHappened")
    
    nonisolated var title: Text {
        MainActor.assumeIsolated {
            Text("***")
        }
    }
    
    nonisolated var image: Image? {
        MainActor.assumeIsolated {
            Image(systemName: "heart")
        }
    }
    
    nonisolated var options: [TipOption] {
        MainActor.assumeIsolated {
            [Tip.MaxDisplayCount(1)]
        }
    }
    nonisolated var rules: [Rule] {
        MainActor.assumeIsolated {
            [
                #Rule(Self.$haveSome) { $0 == true },
                #Rule(Self.eventOneHappened) { $0.donations.count >= 1 }
            ]
        }
        
    }
}

I wrote it like this at the beginning. Although there is no warning now, it looks strange. However, my rules are pretty simple, all it takes is control through Event.

TipKit: How to support `concurrency-safe`
 
 
Q