I'm playing around with SwiftUI in IOS13 beta. After updating my system to beta5 (Catalyst, Xcode, IOS), I experienced a problem with my SwiftUI-shapes that worked well in beta4..
The Path()
constructor in beta5 is constantly returning nil, so my code is crashing when trying to render a SwiftUI shape/path..
While trying to track down the issue I set up a very basic new project with a simple ContentView struct. This project is showing the same behaviour..
So currently I don't believe it's an issue within my project-environment but within the framework..
I also tried to have the path in a struct conforming to the shape-protocol (uncommented code below), but the result is the same: the constructor Path()
in func path(...)
is also returning nil.
import SwiftUI
//struct CheckShape : Shape {
// func path(in rect: CGRect) -> Path {
//
// var path = Path()
//
// path.move(to: CGPoint(x: rect.minX, y: rect.minY))
// path.addLine(to: CGPoint(x: rect.maxX, y: rect.maxY))
//
// return path
// }
//
//
//}
struct ContentView: View {
var body: some View {
GeometryReader { geo in
Path { p in
let p1 = CGPoint(x: 0.0, y: 0.0)
let p2 = CGPoint(x: geo.size.width, y: geo.size.height)
p.move(to: p1)
p.addLine(to: p2)
}
.stroke(Color.black, lineWidth: 1.0)
}
}
}
When I run the code in the simulator (or on the device) and break in the Path-closure, I see that p is nil and as a consequence, the code breaks with a 'Thread 1: EXC_BAD_INSTRUCTION` (code=EXC_I386_INVOP, subcode=0x0)'
Has anybody seen the same behavior and can suggest a solution/workaround?