Live data from Hacker News

SwiftUI in 2022

mjtsai.com

101–110 of 216 posts

Re: SwiftUI in 2022

#101
Context: I’ve been working with iOS full time since a few years before Swift came out.

A few startups ago we built our app using SwiftUI 1.0. At that time, while 90% of it was fantastic, 10% was either unworkable or extremely unreliable, causing for some maddening bugs. The documentation was laughable so for these reasons I chose to do the app for a subsequent startup in UIKit.

Fast forward to my most recent company; decided to give SwiftUI another shot (targeting iOS 14 & SwiftUI 2). I am 100% glad we did. It’s been pretty incredible; we’ve built a reasonably complex banking app at a pace not possible with UIKit. The animations in particular are crazy good to work with; we’ve got some very complex animated flows that would have taken weeks and thousands of lines with UIKit… with SwiftUI it was about 5 days.

It’s definitely not without its downsides; documentation is still slim at best, but there’s plenty of blogs and resources (https://swiftui-lab.com/ is the most helpful IMO) available now. There are also still some maddening bugs that appear in production and take a day or two of head scratching only to discover it’s a bug in the framework (most recently; using #available causes code to crash on the platform it’s protecting against lol), but there are always workarounds. Still, time wasted on these has been vastly outweighed by the weeks / months of time saved.

Finally, you can always use UIKit as an escape hatch through UIViewRepresentable.

iOS 15 is at 85% adoption, so we plan to drop support for 14 somewhat soon, which will give us an even more robust framework as well as async await APIs. Not feasible for most companies I know, but even supporting 14+ Will be pretty reasonable when iOS 16 drops in September.

Re: SwiftUI in 2022

#102

Earlier quoted context omitted.

The point of comparison is that it has given people the ability to develop their own iOS apps from scratch, when previously they could not as UIKit was too daunting and the tools were not as advanced (live preview with swiftui/etc).

SwiftUI is not less daunting than UIKit. In fact I would say that the SwiftUI "magic" is far scarier for beginners than IBOutlets and UIViewControllers

I watched a youtube video about VStacks and Spacers and I was having fun making real layouts my first hour in - with a fast, live preview environment. That was my "oh wow" moment. What's the equivalent with UIKit? Interface Builder is nothing like what's now possible with SwiftUI. I've tried IB in the past and it was not for me.

Re: SwiftUI in 2022

#103
post #54

Earlier quoted context omitted.

> You could write an opposite article featuring people using SwiftUI that have never touched UIKit or iOS code before and it would be nothing but glowing praise. How can one properly evaluate it with no point of comparison? If you've never tasted chocolate, then vanilla might seem like the greatest flavor ever.

The point of comparison is that it has given people the ability to develop their own iOS apps from scratch, when previously they could not as UIKit was too daunting and the tools were not as advanced (live preview with swiftui/etc).

It may have a easier ramp-up, but it also has a huge cliff at the end of the ramp. Once you step off the happy path you're in for an even more daunting experience than UIKit, because SwiftUI doesn't give you much to get below the magic when you need to. Also, previews are fairly constantly broken in my experience. Interface builder has its problems too, but at least it renders the nib every time.

Re: SwiftUI in 2022

#104

Earlier quoted context omitted.

SwiftUI is not less daunting than UIKit. In fact I would say that the SwiftUI "magic" is far scarier for beginners than IBOutlets and UIViewControllers

I watched a youtube video about VStacks and Spacers and I was having fun making real layouts my first hour in - with a fast, live preview environment. That was my "oh wow" moment. What's the equivalent with UIKit? Interface Builder is nothing like what's now possible with SwiftUI. I've tried IB in the past and it was not for me.

> What's the equivalent with UIKit?

UIStackView

> I was having fun making real layouts my first hour in

Good. Now take a pixel-perfect mockup of a new screen from your designer at work and implement that.

Re: SwiftUI in 2022

#105
If you like SwiftUI, I challenge you to a SwiftUI fizzbuzz:

a square, screen width, 10x padding, red background.

inside it, a little square, centered and a little square, top left corner, 10px padding, blue background for both.

Tell me that was easy, so that I know you're lying :)

Re: SwiftUI in 2022

#106

Is anyone using this really? My team is pretty excited about using it but I've been a little more hesitant mostly because I've not read of anyone using it at any sort of scale with success. Even for smaller project it still doesn't seem production ready.

I just finished a contract on an app with 400K users.

It was in pretty bad shape when I got my hands on it. Last update: February 2020. Targeting iOS 11+, mostly UIKit, powered by Cocoapods with 25 dependencies, and 1.3M LOC.

It took me 3 months to rewrite everything from scratch in SwiftUI, with 100% feature parity. Of the ~20 different view/components that I had to write, just one required me to dip into UIKit (with UIViewRepresentable to bridge).

Now the app is iOS 14+, 5 dependencies (all managed with Swift Package Manager) and 6.5K LOC, with 0 crashes in the last month.

SwiftUI is production ready.

Re: SwiftUI in 2022

#107

I'm doing an app integrally with SwiftUI, as always happen with new frameworks, if you stay in the happy path everything is nice and easy, but if you start tweaking things, you are lost in the forest really fast. To give you an example, it's quite easy to add the swipe to delete function (within a list) just adding .onDelete() but if you want to add swipe to delete to a LazyVStack (similar to a List) you need to impl…

I'm probably just getting a bit old, but I like to layout my views manually. I've got a few helpers so I can write `view.left = otherView.right + 8` or `view.moveLeftEdge(to: margins.left` etc. I find it just so clear and easy to understand.

I've not tried SwiftUI yet because my app needs to work on older devices than this allows, but it's also a solution for a problem I don't really have. It can't be as bad as AutoLayout at least.

Re: SwiftUI in 2022

#108

IMO SwiftUI feels limited b.c. it breaks itself away from the UIKit world: React succeeded because it is the DOM with all of raw HTML & CSS, a thin abstraction with official escape hatches. Mixing imperative and declarative code is natural and more abstractions can be built. Instead, SwiftUI adopted a whole new set of primitives that doesn’t mix. Accessing the underlying UIView is discouraged, and wrapping up UIKit i…

There are official escape hatches in SwiftUI to let you leverage UIKit. As someone actively working on a slow migration from UIKit to SwiftUI (where possible), it doesn't feel discouraging to wrap a UIKit view to use it in SwiftUI if necessary.

That’s more of a compatibility solution than an escape hatch. An official SwiftUI escape hatch should have access to the underlying imperative object, call methods on it, etc… Unfortunately the underlying ‘things’ in SwiftUI is implementation detail, inspecting the view hierarchy and finding the UIViews that implement a SwiftUI view is a hack.

Re: SwiftUI in 2022

#109

Earlier quoted context omitted.

The point of comparison is that it has given people the ability to develop their own iOS apps from scratch, when previously they could not as UIKit was too daunting and the tools were not as advanced (live preview with swiftui/etc).

SwiftUI is not less daunting than UIKit. In fact I would say that the SwiftUI "magic" is far scarier for beginners than IBOutlets and UIViewControllers

Beginners love magic, it lets them do things they otherwise couldn't do.

Re: SwiftUI in 2022

#110
post #49

I'm confused by this post. Is it just a random smattering of Twitter sentiment collected into one place?

You’re not wrong; that is the blog’s style. I enjoy the format for exposing me to a cross-section of opinions from across the internet, on topics I find interesting, with very little work on my part. That’s probably more an indictment on Twitter’s product stagnation than a shower of praise on this blog and it’s author.

Additionally, it's not always just Twitter: it can be news, or something from another blog as well.
Post reply on HN