[Xcode 12.1] Circle().trim not drawing after Xcode update

My custom controls stopped working after updating Xcode to 12.1 from 12.

It works in application project, but it doesn't work in Widget Extension.

Sample view that stopped working:

Code Block
struct WidgetsEntryView : View {
var body: some View {
Circle()
.trim(from: 0, to: 0.75)
}
}


If you remove trim it renders correctly. With trim nothing appears. It worked before.

Replies

I think I have a similar problem.

Since Xcode 12.1, my widgets won't display Arcs anymore (Shape, Path, addArc), while e.g. Shapes like Rect still work. I also didn't find anything related to that in release/change notes of Xcode.

So I'm just wondering if this is a bug, or if Apple just put more constraints on Widgets, without mentioning them?! Anyway, this really sux, as my widgets heavily rely on displaying those arcs. :-(

Example:
Code Block
struct Arc: Shape {
    func path(in rect: CGRect) -> Path {
        var path = Path()
        path.addArc(center: CGPoint(x: 50, y: 50), radius: 25, startAngle: Angle.degrees(0), endAngle: Angle.degrees(90), clockwise: true)
        return path
    }
}

I tried this in XCode 12.1:

Code Block
struct ContentView: View {
var body: some View {
Circle()
.trim(from: 0, to: 0.75)
.frame(width: 50, height: 50, alignment: .center)
}
}

It effectively works OK in app.
  • Could you test with frame modifier ?

  • Could you post the complete code with extension, so that we can repeat the test ?


@Claude31 this is some serious issue with Xcode 12.1, I tried with frame and it still doesn't work. I can just switch to xcode 12.0.1 and it works perfectly fine, but on Xcode 12.1 it doesn't. I recorded small demo, but it's not possible to post a url here -.-

Just create a new SwiftUI project, add widget extension target and put this code. It does not render. However, it does work in the host app project.
You can post an URL if you edit a little like https. ://myUrl. .com

Did you file a bug report ?
And did you try with 12.2 beta ?
Yes, I reported the issue (Feedback Assistant). I haven't tried it on Xcode 12.2 beta.
Bug demo: bit. ly/3egWddg