r/iOSProgramming • u/throwawaymycareer93 • May 19 '20
Discussion Don't use SwiftUI on your projects
I knew that this would be painful to start new medium sized project in SwiftUI. I knew at the start that correct choice would be UIKit. I thought I knew all the risks of doing new project on framework that hasn't been around for a while. But I decided that with years of experience and Apple quality behind me I would be able to pull through it. Well I did, kind of.
Couple of pain points that will help you to make a choice:
No adequate documentation. Couple of examples of very simple cases, few sentences on developer.apple that seem to be generated from code and that's it. Hard to find how to do even simple things.
Framework doesn't support 2/3 of UIKit features. Lists and Buttons with different stacks are very shiny and nice, but when it comes to development outside off WWDC presentation you need to bridge ALL the time. No collection views (sick!), image picker, document sharing, appearance, responders, etc, etc. You will need to build representatives and handle them yourself. Your codebase quickly grows, but it feels that you just doing the wrong thing all the time.
iOS 13 only. Not that big of a deal, but definitely not awesome.
State. A. Lot. Of. State. Think of it that way, anytime when your view adds any dynamic behaviour you need to add another state to manage it. Or multiple states depending on complexity of behaviour. You might say, split your views in smaller ones, declare view models, and try to write robust code. But in this case it makes it even worse. Your code plunges into bindings and observedobjects in order to communicate between your views or view models.
BUGS. And a lot of them. In obvious places. NavigationLink doesn't work when you put it navigation bar. Declare it as deactivated one, place button in nav bar and add another state to trigger it.
NavigationLink as a concept doesn't really work. It is an idea that you just pass view and label and everything works, but in real world often you need to perform something immediately before navigating to new screen. Mutate core data, fetch request, call api, you name it. Workaround is that you put button, instead of NavigationLink, do your thing, call view model, update core data etc, and then make NavigationLink active. How do you do that? By toggling state. You see my point here?
No back compatibility. All of those wouldn't be a problem if you could just write your swiftui alongside with UIKit. But no, that is not supported.
Base View type is PAT. No need to comment here. Can't be used as generic constraint, can't support polymorphic behaviour. Quite often you see AnyView() wrapped all over everything.
Error messaging is broken. It doesn't work. Like at all. Points to wrong thing all the time, which slows you down a lot.
Needed to get it of my chest.
2
u/tubescreamer568 May 20 '20
Everybody gangsta until random crashes show up from the simplest NavigationView
2
u/throwawaymycareer93 May 20 '20
Everybody gangsta till you need to present UIDocumentInteractionController and there is no view controller in hierarchy to attach it to.
34
u/so-oag Swift May 19 '20
Thanks for also bringing up the bad parts of SwiftUI. It’s a framework with huge potential, but the hype around it tends to overshadow some issues it still has.
21
May 19 '20
I too did review it on my job and determined that we should wait even though the majority of our customers have moved to IOS 13.
Framework doesn't support 2/3 of UIKit features. Lists and Buttons with different stacks are very shiny and nice, but when it comes to development outside off WWDC presentation you need to bridge ALL the time. No collection views (sick!), image picker, document sharing, appearance, responders, etc, etc. You will need to build representatives and handle them yourself. Your codebase quickly grows, but it feels that you just doing the wrong thing all the time.
This was one other reason why I felt that more components should match feature parity of UIKit tilll it makes sense to use. The only advantage that you could possible hope for is that when they do come out with the controls, they will be a drop in replacement.
State. A. Lot. Of. State. Think of it that way, anytime when your view adds any dynamic behaviour you need to add another state to manage it. Or multiple states depending on complexity of behaviour. You might say, split your views in smaller ones, declare view models, and try to write robust code. But in this case it makes it even worse. Your code plunges into bindings and observedobjects in order to communicate between your views or view models.
I see this as simply getting use to this paradigm. The only thing that SwiftUI is doing is making your state changes explicit. I personally prefer explicit state rather than the way UIKit takes that accidental complexity of mutation and just throws a bed sheet over it to make it much harder to find the source of bugs. Immutability and explicit state are the reason why "on paper" SwiftUI should be more robust than UIKit programs.
20
u/MattRighetti May 20 '20
I've built a lot of SwiftUI apps this year, I would never go back, I agree that it covers 2/3 of UIKit features but simple design and functionality in 1/3 of the time is way better than the other way around. I also agree that documentation is pretty much none but I've never needed it. The only thing I struggled at first was Combine, MVVM and testing those models
16
u/ThatBoiRalphy Objective-C / Swift May 19 '20
hopefully a well improved SwiftUI 2 in about a month
12
10
u/davbeck May 19 '20
I'll add to the list that it always feels like SwiftUI is really stressing the capabilities of Swift, using features of the language that aren't fully baked or building around language features that don't exist yet like variadic generics. If someone else built this library, they would design it differently based on today's limitations of the language but since it's Apple, they built it and then assumed they could push the changes to the language they would need through.
And while I bet there will be major improvements this year, I also bet that those improvements will break a ton of existing code.
10
u/jfuellert May 20 '20
I’m a seasoned Apple developer (7+ years) and I’ve been created our app, from scratch, using SwiftUI. I’ve found that the majority of the given “Kit” components (list, navigation view, etc.) just aren’t ready for production. Instead of trying to work with these incomplete components I found it best to build your own system to mimic these by templating “branding” type lifecycle, transitions, animations, and color palettes.
Once you realize it’s much quicker to role most of your own versions of “kit” components, things start to get much better and development becomes much quicker. The other benefit of this comes in a month when they account SwiftUI 2 and you have to rewrite, though not completely, your “kit” code. Having everything custom alleviates some of those worries. The downside to this is the upfront cost of development.
TL;DR explore the idea of rolling your own version of the components you expect from Apple. As long as you can go against some default conventions, this method will save you lots of time and headaches
0
May 20 '20
[deleted]
2
u/jfuellert May 20 '20
Depends what your goals are. Ask yourself if A: you’re making the app with the intention of cross-form factor support B: your designs are more custom than conventional iOS
If no to both, I’d say stick with UIKit. If yes to both, SwiftUI If yes to A only, SwiftUI will help get you there much quicker, especially for macOS. If yes to B only, it’s really up to your discrediting, but I’d still steer towards UIKit. This all depends on how custom the designs are.
6
u/yachtintransit May 20 '20
Meh, idk it seems to be working pretty well for me. It’s not perfect and I have bumped into many of the aforementioned problems. Additionally it doesn’t make my teeth whiter, my shoes brighter or my kids behave better; but one thing it does do is cut down dramatically on my LOC for equivalent features without pulling in 3rd party dependencies. I’m going to double down on it and see where this train goes, I see the power in it even if it’s not fulfilling the full potential at this immediate moment. 🤷
1
u/BaronSharktooth May 20 '20
Yup, that's the way I see it as well. Some things are incredibly simple, like defining a Shape and building a view with it.
Other things are rather complex, like layout. I feel like I haven't yet learned its intricacies yet. I've been screwing around with the different ways of laying out views relative to each other, for example. You can do that with position modifiers and State, or with alignmentGuide modifiers, or with offsets, or with PreferenceKey and State. Lots of possibilities.
2
May 23 '20
My layout code was messy the first few weeks as I learned what does what. But I have an internal need to make things “right”. I find a lot of things on forums and websites are just bad practice, but a good start. Especially the top results on google, not good sources. But with trial and error I’m writing half the SwiftUI I was at the start and getting exactly what I wanted.
Create many small functions. Keep body tiny and to the point. Create components as their own view, sometimes even if used once. Nesting more than 2/3 levels should be considered a code smell. Put modifiers on their own line and indented.
Take advantage of previews. I usually have one view generate 3 previews at once by using Group. Then initializing different values and setting each preview to a different device type.
2
10
u/well___duh May 19 '20
Another serious bug: NavigationView crashes the app on devices that are larger than an iPhone 8 since iOS 13.4. That alone made me quit SwiftUI until iOS 14.
6
u/awh May 19 '20
I’ve found that it craps the bed if you try to present an alert while a sheet is also presenting, on an iPhone at least.
The first time, it just doesn’t present, but the second time it actively crashes.
5
May 20 '20
It’s so fucking bad, pardon the French.
Have always wanted to do iOS app dev, and had to use SwiftUI for an app dev course.
I really hope Apple at least update the documentation and add helpful error messages in the next release, because shit is a hair-pulling level of frustrating.
5
u/yelow13 May 20 '20
Just wait until you try Xamarin forms (don't)
1
May 20 '20
I am so glad my workplace banned Xamarin.
1
u/yelow13 May 20 '20
I think they were too quick to push Forms. It was overhyped and buggy, but the regular Xamarin.iOS with storyboards worked well
5
u/iSpain17 May 20 '20 edited May 20 '20
I won’t say anything as I had already seen what this community does to people who attempt to dismiss this swiftui hate.
BTW, just a quick question: did you ever even try to understand what the strengths of SwiftUI are? Did you ever try to use it only for that, while writing the rest in UIKit?
I think it's much easier to start a UIKit project, have all your navigation and collectionviews in UIKit, so basically the frame of your application, and do all the simple views in SwiftUI via HostingControllers.
This way you get UIKit's good part (highly customized navigation and collections, without limitations) and you also get SwiftUI's good part (not having to do stupid amounts of code for a single page view, fancy animations quickly).
SwiftUI is not missing a lot (and this will get me downvoted obviously). It is missing some basic protocols, like ButtonStyle etc. but it won't change that much. It should not be used alone, it should be used to alleviate the bothering parts of UIKit - which is by far that you need to write stupid amounts of code for very simple things.
1
May 23 '20
I like SwiftUI. What it’s missing is how I’m supposed to use it. Even Apple’s own tutorial break down if you want to add a 3rd NavigationLink. It’s missing practices and focuses on a single view.
4
May 19 '20
As someone just starting out in iOS development, which one should I learn? I started with the first couple lectures of Stanford’s course from 2017 using UIKit, but switched over to their new 2020 course using SwiftUI. I really prefer storyboard to SwiftUI, but if SwiftUI is the future of new projects then I’d rather not get left behind this early...
11
3
May 20 '20
UIKit is still the standard. If you're looking to get a job in the next 2-3 years, then learn that. It's not going away any time soon. It's probably good to get some familiarity with SwiftUI, as it could very well be the standard in a few years, but as mentioned in other comments, it's still basically in Alpha and is very buggy and unfinished.
2
May 20 '20
UIKit first IMO. SwiftUI is neat, but it's still too new and you're not going to find people in the enterprise world using it anytime soon.
Now, when I say UIKit first, I don't mean "only UIKit", you can still mess around with SwiftUI, just don't make it your prime focus. Instead, when you get an app working with UIKit, try and make the UI portion again in SwiftUI. You're still learning parts of SwiftUI but it's not your main focus.
1
May 23 '20
As someone who has 10years with UIKit, I’m still learning. I try to stay outside of UI in general and mostly develop frameworks, but you can’t avoid UI. I’d learn only what you need to know as you need to know it.
I’d say SwiftUI. It’ll be really hard, but while it’s new this year, it won’t be new next year.
4
May 19 '20 edited May 20 '20
I’ve had so little time to play with SwiftUI. However, I’ve been able to do anything I want in it eventually, including using it with UIKit. I think the only problem is documentation.
Eta: Oh, and the horrible error messages of course.
7
u/arthurdapaz May 19 '20
Yes... I don’t really get all the hype over SwiftUI, in my company we need to support iOS 10*... we are in country that people holds old iPhones for too long... so, it doesn’t make sense to SwiftUI-fy new projects.
Plus... all the above mentioned things. SwiftUI is just a toy, at least for now. (And the next 2-3 years)... (this time projection is not my solely opinion, it’s validated by Apple swift team, who expects SwiftUI to be “older” in this time frame...
2
u/powerje May 20 '20
people holds old iPhones for too long.
dang, I was so happy to drop support for the 5C. Sorry to hear you have to do that!
1
May 20 '20
Could someone explain the backward compatibility (or lack thereof) part please?
4
u/SirensToGo Objective-C / Swift May 20 '20 edited May 20 '20
Apps which use SwiftUI only run on iOS 13 devices. SwiftUI is not a development framework which compiles to binary code or nibs but is a runtime framework. This means anyone who has apps which support versions <iOS 13 (many!) will pretty much never touch SwiftUI.
edit missed a word
0
u/BaronSharktooth May 20 '20
SwiftUI is not a development framework which compiles binary code or nibs but is a runtime framework
Source please? I'd like to know more about this.
2
u/SirensToGo Objective-C / Swift May 20 '20
/System/Library/Frameworks/SwiftUI.framework/SwiftUI is loaded at runtime. I have no idea what it does but the
SwiftUIbinary is 40MB for the pure x64 version so it's definitely doing a stupid amount.1
u/BaronSharktooth May 20 '20
Why would a framework automatically mean that it includes a runtime? As I understand it, a framework is simply a collection of .so files, header files and a bit of metadata so Xcode knows how to link against it.
It may include a runtime, sure. But you can't tell by the fact that it's distributed as a framework right?
3
u/SirensToGo Objective-C / Swift May 20 '20
You're correct but you might be confusing the actual lines between framework and shared library.
sofiles on Linux are the same thing asdylibfiles on Apple platforms. Frameworks on Apple platforms are actually just these dynamic libraries with a little bit of extra packaging to allow developers to include things like helper applications, XPC services, and subframeworks.You can either load them through the Mach-O header (ie compile time dynamic linking) as you mentioned or at runtime using
dlsym. Regardless of how you load this external the code into your binary, you have the same result. You never statically link (aka build the framework into your app binary) against Apple frameworks.Also, sorry, I just noticed but you also may have gotten confused by a small typo I made. I meant that SwiftUI is loaded at runtime, not that it has a runtime. SwiftUI words by executing a whole bunch of code through the framework, it isn't a developer tool which acts at compile time to synthesize UIKit or nib files. This is relevant to backwards compatibility because it means that it literally cannot run on older OS versions as when system tries to launch the app, it won't be able to find the requested dylibs from the mach-o header (
/System/Library/Frameworks/SwiftUI.frameworkin particular) and so the app will just crash.-1
u/BaronSharktooth May 20 '20
SwiftUI words by executing a whole bunch of code through the framework, it isn't a developer tool which acts at compile time
Why do you think so?
-1
u/throwawaymycareer93 May 20 '20
You can't just add 1 SwiftUI view to your project written in UIKit and you can't switch back from using SwfitUI to ViewControllers.
2
u/gistya May 23 '20
You can just use @available checks to wrap the SwiftUI parts so they don't tun on pre-iOS 13. Of course this means you need to supply a plain UIKit codepath for legacy OS's.
1
u/gistya May 21 '20
Op's post contains a lot of false information.
I cannot speak to the Navigation link issue.
100% of UIKit interops with SwiftUI. Op may not understand how to make that work, but that's not SwiftUI's fault.
It is true that Swift 3 and Swift 4 migrations introduced minor churn, but these migrations were not that bad guys.
This does not mean SwiftUI 2 will surely break all your SwiftUI 1 code. SwiftUI is an API, not a programming language.
2
u/throwawaymycareer93 May 22 '20
100% of UIKit interops with SwiftUI.
Do you mean by writing Representatives and pushing Host view controller from the other side?
1
u/gistya May 22 '20
You can wrap any UIView in UIViewRepresentable, and any UIViewController in UIViewControllerRepresentable, then use it in SwiftUI.
As for SwiftUI, you host it in a UIHostViewController, which can in turn be responsible for some subview of a parent UIViewController.
Not sure what you mean by "pushing" it "from the other side" though. Other side of what?
2
u/throwawaymycareer93 May 22 '20
Yes, you wrote exactly what I meant. Those bridges do not work for everything, as there are hidden variables that encapsulate state that is not accessible via UIViewControllerRepresentable/UIViewRepresentable. Look into this thread for more discussion.
As for UIHostViewController it doesn't provide proper bridging, as you won't be able to fully access property modifiers inside and again access evnoriment properly.
Also, writing UIViewControllerRepresentable every time when you run into lack of support from SwiftUI isn't solution, it negates all the point of using swiftui in the first place.
1
u/gistya May 23 '20
Can you give an example of what these "hidden properties" are that you claim blocks the ability to certain UIKit types? And specifically which types are they?
3
3
u/WickedDogg May 20 '20
Error detecting is sh*t in SwiftUI.
3
u/sobri909 May 20 '20
You're allowed to say "shit".
And yes, the error messages are shit. SwiftUI is still very alpha.
3
u/NeverwinterMoon May 20 '20
I am currently building an app which is not too simple using SwiftUI. I've made the decision to use SwiftUI in my company and made my employer aware of all the possible pitfalls, and still was given the green light.
So, about five months in, I've had bad times and good times. At least on two occasions I was so frustrated and pissed with SwiftUI, that I started having thoughts of re-writing everything with UIKit + IB. Sadly, as I was already pretty far in, I've decided against it because of the time it would take.
Overall, I still love a lot about SwiftUI. The thing I hate most is not even the "2/3 of UIKit features support" but the ridiculous bugs. One step left or right from the path that was shown in WWDC and the official tutorials and all hell can break loose.
If I could go back in time, I would most definitely start with UIKit instead on my current project. Nonetheless, my app at its current state was done according to our UI/UX designs and works as expected in 99% of the cases (I still have corner cases because of NavigationView). The pain I had on my adventure is unforgettable though.
3
u/sobri909 May 20 '20
Meh.
I'm doing fine with SwiftUI in the next major release of Arc App so far.
Yes it's still alpha. Yes there's a lot of stuff missing. Yes there's a lot of bugs. But where it does work, it's much cleaner and simpler code, with dramatic workflow and tooling improvements over what came before.
And for the parts that are missing or incomplete, you can still use UIViewRepresentable or UIViewControllerRepresentable to use good old UIKit to fill the gaps.
The first few weeks of SwiftUI are all about learning where not to step (because that part hasn't been built/finished yet, or is buggy), and how to adapt to the dramatically different approach. But once you get over those hurdles, it's much cleaner and faster to build with.
I won't be shipping my next update for a few more months yet, so I'm hoping that there'll be an iOS 13.6 with SwiftUI updates before then. But if I had to ship without that, I'd still be able to manage, and wouldn't regret having moved to SwiftUI so early.
5
u/darkmoody May 19 '20
Yes, I totally agree with this. SwiftUI is a horror show as soon as you start building your second screen.
4
u/chackle May 19 '20
Good to hear a perspective similar to my several experiences rather than always reading "wow swift ui awesome. Write an app in three lines of code!". Its just so restrictive and messy currently
2
2
2
u/darkmoody May 21 '20 edited May 29 '20
Thanks for your post. This has been exactly our experience with SwiftUI too. I've documented the SwiftUI drawbacks here
3
u/powerje May 20 '20
If the next major iteration of SwiftUI doesn't have backports to iOS 13 it's a travesty
4
u/BaronSharktooth May 20 '20
I don't expect it to get a backport, to be honest.
1
1
1
u/zeiteisen May 20 '20
It’s like the release of autolayout. You couldn’t use it seriously in the first year. After one year it was way better. I expect the same for SwiftUI
1
1
May 23 '20
I disagree. Sure, the docs suck and there’s a lot of nuisances, but I’ve never used a perfect API in my life. I find swift bugs all the time, like new ones I I created and got confirmed on bugs.swift.org. Hasn’t stopped me from using Swift since it came out, just gets better.
Further, I’ll add I’ve developed and deployed a production app in SwiftUI at my company. It’s not a small user base in any means. There were surprises and hard times, but I sure do like it more than UIKit. It’s been in production for a while now and our users have not said anything wrong about it.
1
u/lordzsolt May 19 '20 edited May 19 '20
I mean, it was obvious a toy thing. Same as when Swift came out. It didn't make sense to start a project in it for a year or two. I think version 2.3 was the first usable one. You summarised it quite well. It's for buttons and labels :)
NavigationLink I also hate. It's Apple's way of tightly coupling navigation to views, which you have to bend over backwards to deal with. As you've said, often there's logic to what view you open.
I just want to address one thing, that being regarding state. First, you should probably use Combine. And then, I'm actually very much looking forward to having smaller views with view models and parent view models built on top of them. So far every project I had to work on, people put everything related to one screen into one view model because it was "easier, because you don't have bindings to communicate between view models". But that is exactly what an abstraction layer is. So instead of having an abstraction layer above small views that a big view model merged together, you had a single view model managing EVERYTHING on the screen. And you'd end up with a 1500 line file with 100 variables declared in them.
1
u/ElectricalDelivery May 20 '20
/u/rhysmorgan please explain us how we are wrong and building apps with SwiftUI is ok
1
u/gistya May 23 '20
I think it depends on what exactly you need to do.
Like if all you are doing are simple forms, and by the time you need to do something complex we will have SwiftUI 2, then you might be feeling pretty good.
Because if your current project is simple enough to fall within SwiftUI 1's wheelhouse, and we know everything will eventually go to SwiftUI, if you're building for the future then you might well start on SwiftUI now.
But if SwiftUI 2 only supports iOS 14 and higher, that might be a dealbreaker for many.
-5
May 19 '20
Amen to that. I am a professional iOS developer and don’t know a single developer taking SwiftUI seriously atm. It’s half baked so far. Check out Flutter for iOS development if you are intrigued by SwiftUI....Apple basically sherlocked SwiftUI from Flutter.
4
-5
May 19 '20
Isn’t Apple forcing all apps to use ios13 sdk in the next few months? Made me think I’ll get left behind if I don’t start in swiftUI
15
u/FVMAzalea Swift May 19 '20
They’re requiring iOS 13 SDK, but your deployment target can be lower than iOS 13 still. So you’ll still be unable to use SwiftUI if you want to support iOS 12, 11, or below.
7
12
u/lordzsolt May 19 '20
Highly doubt it. They still accept Objective-C.
They deprecated UIWebView like 5 years ago and only now forced everyone to use WKWebView.
6
u/metro6audio Objective-C / Swift May 19 '20
You have to build against the iOS 13 SDK, but that doesn't mean you have to target only iOS 13+, which is required for Swift UI. They're just requiring the updated toolchain.
-2
u/acroporaguardian May 19 '20
Im amazed that a company of their resources didn't try to make Swift the next Unity. By having iOS they would have had a huge advantage when it comes down to choosing a framework/language. They could have gotten 5% of all Apps made with and given a 5% discount on App store publishing with it so that the net impact would be getting 5% from Apps sold on Android/Windows.
They of all people should know that getting a cut of others people works is the way to go.
0
May 19 '20
[deleted]
22
u/MattRighetti May 20 '20
I would not call this an Alpha, more like a beta. I've built a lot of apps in SwiftUI this year and it took like 4 times less the hours I've spent with UIKit and the design outcome is way better imo. Hopefully later in June SwiftUI 2.0 will be even better.
8
u/tangoshukudai May 20 '20
Your apps must have been very simple. Also IB / AppKit/UIKIt are not that difficult.
4
u/MattRighetti May 20 '20
Not really simple, the problem with SwiftUI are details but when you can’t do something you can always make it work by wrapping UIKit code which is handy
0
May 20 '20
[deleted]
2
u/MattRighetti May 20 '20
Nope, I’ve been an ‘all-code’ guy so I’ve always programmed UI by code
0
May 20 '20
[deleted]
7
u/powerje May 20 '20
For a simple UI that doesn't require dropping into UIKit I can kinda believe it. Anything more complex does seem problematic though.
Paul Hudson had a video where he compared time building a simple UI in UIKit vs SwiftUI when he was very new to writing SwiftUI:
1
u/MattRighetti May 20 '20
Agreed, but that’s ok since it’s v1.0
1
u/powerje May 20 '20
I mostly agree with that. It's mainly problematic because when the good improvements come out in iOS 14 and 15 they wont be backported to work with 13, so we'll be stuck using the older APIs for years.
0
May 20 '20
[deleted]
1
May 20 '20
Not using SnapKit shouldn't be a deal breaker. Many people don't use third party libraries and IMO SnapKit isn't even necessary if you know what you're doing with constraints.
And view code in the view controller is fine. Now if you're building a bunch of reusable components, or have special styles for UIElements and stuff then it makes sense to make a custom control or class, it all depends on how your app is structured.
1
u/powerje May 20 '20
I think it makes sense to put view code in the view controller. I mainly write MVVM style code and VCs fit into the View layer better than anything else. I also don’t think pulling in SnapKit or other 3rd party frameworks is a suitable comparison of SwiftUI vs UIKit.
0
May 20 '20
[deleted]
3
u/powerje May 20 '20
I’m not against using SnapKit (my company maintains a similar OSS project that we use and I use in my personal apps). I’m just saying to compare UIKit vs SwiftUI pulling it in feels like cheating!
And I’ve seen horrific VCs too. Admittedly written a few like that 😅. These days my VCs layout views and bind to the ViewModel - they rarely contain any conditionals.
1
u/MattRighetti May 20 '20
Well I was not at all an experienced UIKit developer, it’s a lot more verbose and it also encourages MVC. SwiftUI makes (simple UIs for now) a lot faster to develop and control thanks to combine and the MVVM pattern imo, for sure in 2-3 years it will be the absolute iOS standard and UIKit will slowly die. Also remember that SwiftUI is a lot easier for the Apple guys to review which makes a lot of sense
0
u/BillONeillDesignLLC May 24 '20
When SwiftUI works, the speed-up is phenomenal - especially vs IB... MUCH greater than 4x!!! More like 10x - 20x!
When it crashes, it is lethal because there is such poor error checking! The resulting debugging attempts (thrashing around) soaks up all the productivity gains and ends up being less productive than UIKit with IB or pure code...
The issue is that they tried to use Swift language extensions rather than build a custom language compiler (E.g. Java vs Javascript...)
33
u/lordzsolt May 19 '20
Unfortunately, that's Apple's spiel in general. They always pitch things as "revolutionary", "life-changing", "solves world hunger". But you need to wait 1-2 more iterations before it lives up to the hype. Though it's a good way to get early adopters, whom I'm very thankful to, for ironing out the rough edges.
7
May 20 '20
i was one of those idiots that stood in line for 8 hours for the very first iphone. I'm talking OG iphone in 2006. I spent ~$800 that day and couldn't even send a picture text LUL meanwhile all my friends with their flip phones were playing games and sending MMS / picture texts. I remember it took almost 2 years before we could start sending picture messages. Apple is ahead of it's time sometimes, but Apple is always behind at the same time. It's a weird marriage for them
1
0
May 19 '20
[deleted]
24
u/AsidK May 19 '20
Hard disagree there, it’s so much nicer to work with than objective c (albeit less powerful)
7
u/evilgwyn May 20 '20
Good job Apple you made a language better than objective c must have been tough
0
May 19 '20
[deleted]
4
u/powerje May 20 '20
Genuinely curious what hype you're referring to. What was promised that wasn't delivered in the core language?
Now, the tools have tons of issues, SPM for example, error messages in the compiler, the compiler itself crashing - but the core language seems good
0
May 20 '20
[deleted]
2
u/powerje May 20 '20
Chris is pushing its use in TensorFlow at Google. I’ve tried some server side Swift and it’s painful relative to Go. I see where you’re coming from.
2
u/mikerz85 May 19 '20
It’s a modern language and definitely has some great areas. I was most let down by the idea that you don’t lose any performance vs objective C or C; Swift is a syntactically rich language but it’s just not very good with performance. In specialized circumstances, it can in fact match the performance of C++, but that’s rarely the case.
You’ll need to bridge with Objective C and implement in C or C++ for really demanding stuff.
0
May 20 '20
[deleted]
-1
u/mikerz85 May 20 '20
Well, there are just things you’d never want to attempt with it. I don’t imagine anyone is going to write a video decoder in swift. It’s mostly just a good language for good UI handling and basic data wrangling. It is good at making things conceptually neat and easy to follow.
0
May 19 '20
[deleted]
5
u/rowgw May 20 '20
I struggle to learn Swift even after i learnt Kotlin and many years from Obj-C and Android Java.
I am kind of weird and unpopular among other developers that can learn Swift fast.
1
Nov 03 '20
[removed] — view removed comment
1
u/AutoModerator Nov 03 '20
Hey /u/ALL_ONE_SUN, unfortunately you have negative comment karma, so you can't post here. Your submission has been removed. Please do not message the moderators; if you have negative comment karma, you're not allowed to post here, at all.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/TheLastBlackRhino May 20 '20
I used Swift 1 for several real paid projects and it worked absolutely fine. Granted these were start-from-scratch and relatively small (made for a design agency). Sounds like a shame SwiftUI is tarnishing Swift's good (in my eyes) name!
0
May 20 '20
[deleted]
8
u/ohfouroneone May 20 '20
As someone who did both React Native and SwiftUI, you might be disappointed with RN. It's not really better than SwiftUI, and at least SwiftUI is Swift.
1
u/yelow13 May 20 '20
Meh, not a huge fan of RN. UIKit/XIBs aren't great but they're still the best IMO
3
u/the_d3f4ult May 20 '20
It they opened up the "internals" to us .. it would fix most of the problems with it. You currently can't build views, or wrap them in SwiftUI without reinventing half of the modifiers or some things you cannot do at all.. If they opened up the hidden keys from environment (yes, they have a ton of hidden keys, you can access them using Mirror currently, but using reflection to hack Apple's private APIs isn't ideal) and in general allowed developers to build in SwiftUI components on equal level with ones present in SwiftUI I would use it and wouldn't even blink.
I see SwiftUI as a replacement for Storyboards and the dreaded "Programatic UI" rather than a replacement to UIKit. UIKit is still used underneath, and SwiftUI just layouts and configures the UIViews.