Anyone did the full switch from Swift to SwiftUI ?
I personally find the learning of SwiftUI kind of hard....
I personally find the learning of SwiftUI kind of hard....
Sounds good - If you have issues with it just shoot a message; wish you good luck with it!
I’m new here and I already like the place 👍
SwiftUI doesn't seem ready for prime time right now, but might become so after WWDC. More tutorials might become available after that. So I'd wait a few months to decide, and just play with UIKit til then.
I think that depends on your application. I am building something new in SwiftUI now. So far I've not found anything that's impossible. And very little that requires dropping out to UIKit. There are some glaring missing items (no colour picker!) but it's surprisingly well formed for v1. I do wish the compiler errors on complex views were clearer though
This would be my biggest complaint. Errors can show up on a line that is nowhere near where the line with the actual problem is. Has confused me more than once.I do wish the compiler errors on complex views were clearer though
This would be my biggest complaint. Errors can show up on a line that is nowhere near where the line with the actual problem is. Has confused me more than once.
They still do that for you? Haven't had that happen much since the beta period for Catalina ended, but then again I've also mostly still used UIKit
I never had the “pleasure” of the beta. I too still see errors on weird lines. Frequently an error anywhere in the view causes an error on the var body : some View line. Most often this is when you have a typo in a binding variable name for example.
2020-06-05 12:57:14.415590+0100 <app name redacted>[4252:229727] precondition failure: attribute failed to set an initial value: 359
GeometryReader{ screen in
…
if screen.size.width > screen.size.height
return GeometryReader{ screen in
...
if !self.orientation.isPortrait {
So I've hit one of those annoying SwiftUI problems. And this one, for now, I can't seem to resolve. If I navigate to a specific view/view state in landscape mode the app crashes. Same navigation in portrait works. Rotating from portrait to landscape on that view also works. The view in question has a state object associated with it and depending on the state displays one other view (basically a big switch statement: a routing view). If I replace the view being displayed with Text("Test") all is fine. So it's something in that view but I can't work out what! The debugger/error message is, as expected with Swift UI, useless!
Console shows:
Code:2020-06-05 12:57:14.415590+0100 <app name redacted>[4252:229727] precondition failure: attribute failed to set an initial value: 359
Debugger never seems to load!
Ha! Fixed it.
Instead of this:
Code:GeometryReader{ screen in … if screen.size.width > screen.size.height
this does not crash and has the same intended result
Code:return GeometryReader{ screen in ... if !self.orientation.isPortrait {
orientation is an ObservableObject from the environment that tracks orientation changes. Note I still need the GeometryReader to get the safe area insets (which does not crash)
Wow that was a good call on how to fix it. They both seem like the same thing!
I get SwiftUI not being event driven etc. I always hated coding a view though. Moreover it seems a noob will have a pretty hard time grasping what is going on. So many closures...