Xcode 16 Beta: Animatable + non isolated protocol requirement errors.

Here's some simple sample code which produces warnings (or errors if using Swift 6 language mode), annotated with the errors:

struct MyEffect: GeometryEffect {
    var animatableData: CGFloat // ERROR: Main actor-isolated property 'animatableData' cannot be used to satisfy nonisolated protocol requirement

    func effectValue(size: CGSize) -> ProjectionTransform { // ERROR: Main actor-isolated instance method 'effectValue(size:)' cannot be used to satisfy nonisolated protocol requirement
        ProjectionTransform(.identity)
    }
}

I run into the same issue with Shape:

private struct MyShape: Shape {
    var foo: UnitPoint = .zero
    var animatableData: CGPoint.AnimatableData = .zero // ERROR: Main actor-isolated property 'animatableData' cannot be used to satisfy nonisolated protocol requirement

    func path(in rect: CGRect) -> Path {
        print(foo) // ERROR: Main actor-isolated property 'foo' can not be referenced from a non-isolated context
        return Path()
    }
}

It seems that by conforming to these protocols (which share Animatable conformance), all properties within the struct become annotated with @MainActor. Is this a bug?

same here:

struct ShakeEffect: GeometryEffect { var position: CGFloat var animatableData: CGFloat { //same error as in original post here get {position} set {position = newValue} }

init(shakes: Int) {
    position = CGFloat(shakes)
}

func effectValue(size: CGSize) -> ProjectionTransform { //same error as in original post here
     ProjectionTransform(CGAffineTransform(translationX: -30 * sin(position * 2 * .pi), y: 0))
}

}

ideally the protocols would be updated and restricted to main actor, but I don’t hold out much hope for that based on other threads I have read.

Interestingly enough, you can get animatableData to work if you mark the computed variable as nonisolated. Xcode will fail at previewing the result, but a live run shows it working..

struct ContentView: View {

    static let bigAngle = 60.0
    static let smallAngle = 10.0
    @State var angle = Self.bigAngle
    var body: some View {
        MyShape(angle: angle)
            .foregroundStyle(.tint)
            .frame(width: 300, height: 200)
            .animation(.smooth(duration: 1.0), value: angle)
            .onTapGesture {
                angle = angle == Self.bigAngle ? Self.smallAngle : Self.bigAngle
            }
    }
}


struct MyShape: Shape {
    init(angle: Double) {
        self.angle = angle
    }

    var angle: Double
    nonisolated var animatableData: Double {
        get {angle}
        set {angle = newValue }
    }

    func path(in rect: CGRect) -> Path {
        Path { path in
            path.move(to: CGPoint(x: 0, y: 0)) // top left
            path.addLine(to: CGPoint(x: max(0,rect.width - rect.height*tan(angle * .pi/180)), y: 0)) // top right (or top left if the angle is large enough)
            path.addLine(to: CGPoint(x: rect.width, y: rect.height)) //bottom right
            path.addLine(to: CGPoint(x: 0, y: rect.height)) // bottom left
            path.closeSubpath() // Close (back to top left)
        }
    }
}
Xcode 16 Beta: Animatable + non isolated protocol requirement errors.
 
 
Q