Drawing Paths and Shapes tutorial won't compile

I'm going through the newly published SwiftUI tutorials, in particular Drawing Paths and Shapes here: https://developer.apple.com/tutorials/swiftui/drawing-paths-and-shapes


In Step 4 of 5 "Combine the Badge Foreground and Background", intermediate step 3 you are required to add the GeometryReader code to the body variable...


var body: some View {

ZStack {

BadgeBackground()


GeometryReader { geometry in

self.badgeSymbols

.scaleEffect(1.0 / 4.0, anchor: .top)

.position(x: geometry.size.width / 2.0, y: (3.0 / 4.0) * geometry.size.height)

}

}

}


But Xcode complains after adding the GeometryReader that the ZStack trailing closure is "Unable to infer complex closure return type; add explicit type to disambiguate"


Am I missing something? To my eyes, my code is identical to the tutorials.


I decided to compile the Complete version of the tutorial that comes with the downloaded zip. That seems to compile without complaint. Here's a screenshot of the two source code files side by side. https://imgur.com/azzjjx9

Accepted Reply

In the image you attached, line 31 has a typo. It ends with geometry.size.heigh

(no in height.) It'd be nice if the Swift compiler would pinpoint these problems more precisely—I think that's something that the compilers team at Apple is working on.


—Chris

Replies

In the image you attached, line 31 has a typo. It ends with geometry.size.heigh

(no in height.) It'd be nice if the Swift compiler would pinpoint these problems more precisely—I think that's something that the compilers team at Apple is working on.


—Chris

Thanks, and well spotted! I went over it line for line several times and never spotted that.


Of course, now it's telling me their's no such module as 'SwiftUI'. It also doesn't like the opaque data type related 'some' keyword and I can't find any of the simulators to build against. I guess it's still very much in beta. :-/

One thing that I find is really helpful with the strange errors during this beta process is using the clean build folder option. Basically, if I get an error on a build, I do that and retry the build before even bothering to look for a typo. I'd say about 30% of the time, that solves the problem.


Still leaves 70% as my own typos or misunderstandings, but 30% is a lot 🙂