Firstly, sorry for my english, thats not the best, but I will try my best.
I would like to develop a Swift UI app (im beginner) on a virtual machine (XCode version: 11.7, OS: macOS Catalina version 10.15.6.) I gave the virtual machine 8 giga ram and 2 core resources. As the code grew, XCode became slower and slower. Due to the above error, the code doesn't even build anymore.
The error: The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions.
What exactly could be causing the error? Do u have any tips, how I can increase the speed of XCode and avoid that error? I would be very grateful if someone could help me with this problem
Code:
import SwiftUI
public struct ClockView: View {
var width = UIScreen.main.bounds.width
public var body: some View {
ZStack {
Circle()
.fill(Color.gray).opacity(0.2)
ForEach(0..<60) { idx in
VStack {
Rectangle()
.fill(Color.primary)
.opacity(1)
.frame(width: 2, height: idx % 5 == 0 ? 15 : 6)
Spacer()
}
.rotationEffect(.degrees(Double(idx) * 6))
}
Spacer(minLength: 0)
ForEach(1..<13) { idx in
VStack {
Text("\(idx)")
.font(.system(size: 25))
.offset(y: 12)
.rotationEffect(.degrees(-Double(tick)/12 * 360))
Spacer()
}
.rotationEffect(.degrees(Double(idx) * 30))
}
Spacer(minLength: 0)
/*sec*/
Rectangle()
.fill(Color.red)
.frame(width: 1, height: (width - 160) / 2)
.offset(y: (width - 160) / 4)
/*min*/
Rectangle()
.fill(Color.gray)
.opacity(0.9)
.frame(width: 2, height: (width - 200) / 2)
.offset(y: (width - 180) / 4)
/*hour*/
Rectangle()
.fill(Color.primary)
.frame(width: 3, height: (width - 220) / 2)
.offset(y: (width - 220) / 4)
Circle()
.fill(.primary)
.frame(width: 8, height: 8)
Circle()
.fill(.primary)
.frame(width: 4, height: 4)
}.frame(width: width - 80, height: width - 80) /*!!!error here!!!*/
}
}
struct ClockView_Previews: PreviewProvider {
static var previews: some View {
ClockView()
}
}