Missing dot causing strange problems without warning or error

I just stumbled upon a problem where the preview screen loads very long, the fans of my MacBook get loud and after a while preview says:

"Updating took more than 5 seconds"

Building an running the app didn't show any errors or warnings but the simulator just showed a completely black screen when running the app.

After going through my code line by line I found out that all those strange problems where caused by a missing dot.

Code Block swift
MyCustomView()
.padding()
onTapGesture {
self.showContent = true
}


How am I supposed to debug my code when XCode doesn't show me any error or warning and such simple mistakes can cause preview going crazy and simulator displaying a black screen?

I really really love SwiftUI, but I hope there is anything helping me to debug strange SwiftUI behaviour.

XCode doesn't show me any error or warning

It is hard to detect such mis-usage.
onTapGesture is defined as an instance method in an extension of View.

I guess your code exists in a definition of body
Non-dot-leaded onTapGesture is treated as self.onTapGesture as well as other instance methods.
Which may cause infinite recursive call, and the fan goes crazy...

You need to pay extra care when writing code of body.


One more, hard does not mean impossible.
If you think Swift compiler should detect this sort of mis-usage, you should better send a feedback to Apple.
Missing dot causing strange problems without warning or error
 
 
Q