Shapes now add Sendable Warnings. How to resolve?

I've started running into warnings like Stored property 'bezierPath' of 'Sendable'-conforming struct 'ScaledBezier' has non-sendable type 'UIBezierPath' on properties declared within shapes.

This can be easily replicated with a code snippet from a HackingWithSwift article:

struct ScaledBezier: Shape {
    let bezierPath: UIBezierPath

    func path(in rect: CGRect) -> Path {
        let path = Path(bezierPath.cgPath)

        // Figure out how much bigger we need to make our path in order for it to fill the available space without clipping.
        let multiplier = min(rect.width, rect.height)

        // Create an affine transform that uses the multiplier for both dimensions equally.
        let transform = CGAffineTransform(scaleX: multiplier, y: multiplier)

        // Apply that scale and send back the result.
        return path.applying(transform)
    }
}

In this snippet, bezierPath doesn't conform to Sendable, and produces a warning. We could do
extension UIBezierPath: @unchecked Sendable {} to effectively silence the warning until Apple conforms UIBezierPath to Sendable, but I'm curious if anyone has a better option, or has run into similar issues within Shapes when migrating to Xcode 15.

UIBezierPath is mutable, so it is correct that it is not Sendable. If your struct doesn’t expose the path in a way that allows others to mutate it (and doesn’t mutate it itself), you can mark your struct Sendable; otherwise it is correct that you have to use some kind of wrapper to send your struct from one thread to another.

If your struct doesn’t expose the path in a way that allows others to mutate it (and doesn’t mutate it itself), you can mark your struct Sendable

Yeah this would seem appropriate for my use case, where it's just passed in as a constant and used to define the Shape's path. I'm not sure the approach you suggest works for this case though to avoid the warning, as the struct is already Sendable right? Because it conforms to Shape, which itself conforms to Sendable.

What I did find to avoid the warning is that I can use sendable closures, but this feels overly complicated for what I'm trying to accomplish, which is just to create a Shape from a UIBezierPath.

struct ScaledBezier: Shape {
    let bezierPath: @MainActor @Sendable () -> UIBezierPath

    @MainActor
    func path(in rect: CGRect) -> Path {
        let path = Path(bezierPath().cgPath)
        ...
    }
}

This would ultimately get used in SwiftUI like this:

ScaledBezier {
    myUIBezierPath
}