How Swift 5.3 enhances SwiftUI’s DSL
swiftbysundell.com
swiftbysundell.com
On the other hand, it doesn’t quite feel ready. SwiftUI seems to be missing enough components that I end up needing to know how to use the existing AppKit stuff with autolayout, or know how things work under the hood to debug SwiftUI oddities. On top of that, there are few resources out there for learning macOS dev specifically — tons of stuff for iOS, which sorta translates, but not perfectly. I’ve been learning from the Hacking with macOS book, which is very good, and plenty of trial and error.
The other ding against SwiftUI for Mac dev seems to be that it’s only supported in Catalina, and it seems an awful lot of Mac users have held back from updating, so the user base might be diminished.
Most of these seem like temporary problems, but as a newcomer to this world it’s hard to tell if it’s too early to commit to SwiftUI.
It's rapidly improving, though. The version of SwiftUI shipping in iOS 14 and Big Sur are massive improved compared to the current version. If Apple can keep that rate of improvement up, it will reach parity with UIKit/AppKit within another release or two.
For example, say I'm presenting a modal with a simple form. I'd use UIKit's UINavigationContoller to present the modal view, and within the modal's view, I'd have a UIHostingController which encapsulates the SwiftUI-defined form user interface. I can define form layouts (and other simple layouts) much quicker in SwiftUI than I can in UIKit, so I'm finding SwiftUI to be very helpful in that regard.
The majority updates fast - even more so when a 2nd update (Big Sur) comes out, few will hold to before Catalina.
With macOS it makes no sense to "hold out" from upgrading long. You are either prepared to get on with the program and move on, or you're left behind, worse than e.g. on Windows etc.
On the other hand, this makes the platform faster to move forward, adopt new things, and keep a more consistent UI doing so (Windows still have 5-6 UI layers from previous APIs/decades, depending on the app you use -- even for internal MS apps, e.g. you can still open an ancient version of the control panel from within the current one).
I'm normally a pretty quick upgrader, but the MacBook on which I'm typing now will remain on Mojave until the day it dies.
From Apple perspective it's way better that Catalina take all the blame and not the new products and the technology they are betting on for the next decade.
Also developers that care about MacOS platform were even more incentivized to finally upgrade to 64-bits after the 10+ years deprecation warning so that more Apps will be ready on day one for custom silicon.
Here's another nanovg based gui toolkit in cpp https://github.com/wjakob/nanogui
Thanks to Rust macros, you can shape the language to be essentially whatever you want.
I think that ECS (entity component system https://en.wikipedia.org/wiki/Entity_component_system) is the way go with GUIs.
I like the control a lot, with Cocoa, I felt really constrained sometimes.
A key point of a shared UI toolkit is that users can bring their knowledge from one app to another. A standard Cocoa table view or text view has tons of advanced behaviors: type select, keyboard shortcuts, etc. It's worth the user's time to learn these because they work in every app.
But apps where these don't work feel discordant and frustrating.
It is much, much better to use Apple’s toolkits.
There are an infinity of little things like this. macOS is powerfully integrated across the platform and you either play ball with it or you don't.
One that's pretty important is accessibility. You're leaving the blind, vision-impaired, and paralyzed users out in the cold, because macOS has a fairly complete system for all those users to make use of the operating system. But it won't work for an app that isn't native.
But all of them need to work, along with system-wide custom ones.
Text substitution is also an issue.
Honestly, don't let these comments get you down. It's important to act strategically of course, so it doesn't make sense to over-invest in an idea succeeding. But it makes sense to do scoped experiments / proof-of-concepts. I don't think we're "done" with UI framework architecture design, people need to keep trying new things in the space. And I also don't think only Apple (eg. SwiftUI) and Google (eg. Flutter) are allowed to work on these things and we need to accept their gifts from above. Some times, a good quality here is almost not believing that something is too hard to do (while obviously also informing oneself about as much existing work there has been as possible to incorporate it into the experiments).
Yeah. Once you add hierarchy, event handling, windowing, and layout to a rendering engine you pretty much have a basic toolkit.
Kind of like once you've hand built a cpu, gpu, logic board, hard drive, and so on, on top of 3d-printing a case, you have a basic PC.
tree views (with non-textual cells)?
nested menus?
file selection dialog?
Drawing buttons and windows is easy, the problem is the rest.
UI platforms as a rule are always terrible, but there’s inevitably a whole lot of baby in the bath water.
It's not baby with the bathwater, the second you want something cross platform, your choices are electron or qt? Neither is that great of an option.
Last year Voice Control: https://www.apple.com/macos/catalina/docs/Voice_Control_Tech... came out and is absolutely stunning and free with accessibility labels.
A custom UI would force them into “grid mode” on page 6 off the bat while it’s almost too easy if you just stay native, UI tests interact with the app through accessibility labels for example, and obviously we’re all testing, right?
Simply riding closely on the back of the behemoth that’s weirdly good about accessibility gets one very far, very fast.
Cross platform wasn’t even mentioned or implied in your original comment by the way, it was edited into the second one where you narrowed an “arthritic, farsighted Arabic speaking user” into “arthritic”.
I’d rather pay $50 for a native macOS application that uses the UI toolkits offered by its platform and respects the conventions and the system as a whole, than to pay $5 for an application that allegedly does the same thing but which feels broken, sluggish and/or incoherent because its developers are making something cross-platform.
There are some exceptions to this – some developers do pull it off, and if what they make is both good quality and performant and the tool is offering something of exceptional value to me then I will use it. But in the general case, I will avoid the non-native experience.
All of that being said, I still think it is cool that people invest time in exploring making their own GUI frameworks. All I am saying is that it has a cost for the users a lot of the time.
Cross-platform GUI always leads to compromise.
I think it's ultimately what Apple intends to make the flagship way to develop on their platforms. Catalyst exists mostly as a way to pull existing iOS apps and iOS developers under the Mac umbrella.
I didn't speak to developing for macOS specifically. The tldr is that it's not quite production-ready but it's easy to mix SwiftUI with UIKit so you can adopt it incrementally. I really like Apple's vision for SwiftUI and they're catching up with missing features very quickly.
1. There is no way to bundle SwiftUI / Combine to the app so you can ship to earlier iOS versions, making development exclusively done on newer OS version. More over, for any bug fixes on SwiftUI / Combine, you have to wait for the OS updates for the fix. Just updating your Xcode is not enough.
2. While the SwiftUI required language features are all upstreamed to Swift language, and core developers have been patient to articulate why. If SwiftUI / Combine development was done in public (i.e. open-source), bug-fixes and language improvements will be much smoother.
To Apple, point 2 probably is a big leap. But they've done Swift open-source release, and it works relatively well with a sizeable open-source ecosystem on other platforms now.
https://developer.apple.com/documentation/combine
Unfortunately my client’s App still requires iOS 11.
I’ve ported a few different AppKit interfaces to SwiftUI “1.0” on the Mac and the tech is pretty impressive; I am looking forward to exploring the Big Sur version of it.
The biggest problem they have right now is that subtle but important behaviors are being lost in the SwiftUI versions of controls, and they need to add them back. You start to notice how maybe keyboard focus isn’t quite the same, certain key bindings don’t work, tooltips aren’t present, etc. and it adds up. It is really quite easy to get something working in SwiftUI right now but it is really hard to polish it to the standards that Macs used to have.
Also the relative fragility of large swift projects with multiple dependencies has been a recurring frustration. It's been refreshing to work with Cargo, and not have to worry about doing surgery on a project every time a language update is released.
Or have I misunderstood your comment?
Swift had to interop with objective-c right from the start, which itself had to interop with C. SwiftUI feels like a wrapper over UIKit (or at the minimum CoreFoundation).
All in all, it seems impossible that so many layers of compromise over so many years, can lead to anything clean in the long run.
Using UIKit is just Apple current implementation strategy right now. That doesn’t comprise the SwiftUI model & semantics in any meaningful way. It doesn’t feel at all like a wrapper over UIKit IMO. It’s a completely new beast...
I'm really impressed by SwiftUI, it seems like Apple took a couple hundred really good UI engineers and threw them at this. Coming from a web background it's really refreshing to have these APIs. Swift as a language is part of it, changes to JavaScript like those mentioned in this article would be hard to come by (for good reason!)
Like all Apple efforts it was crafted by a small, tight knit cross-functional group of stellar engineers.