SwiftUI: Almost Too Much Fun
June 12, 2019
In my previous post, I described the JDBP band app I want to build and the technologies introduced at WWDC 2019 that I think might make it much easier to create.
Part of the process is exploring these new technologies and SwiftUI is first on my list.
As I’m playing with SwiftUI, I’m not thinking too much about the app I want to build. For me, and probably many others, my first step beyond watching videos and walking through tutorials is to play with it, use it to build a few small throwaway apps, and try to develop as good a feel for it as I can in a short period of time.
I’m not at a point where I can nitpick over whether I agree or disagree with this or that design choice in the framework. I definitely don’t know it well enough yet.
Currently, I’m in the process of building up my mental model of how all of this works. This also includes mentally diffing that model with my existing mental models of AppKit and UIKit.
That’s a lot of brain cycles. This is going to take a while and is probably also going on as a background process as I sleep.
I found these two sessions really helped me begin to build that mental model of the frameworks beyond tutorials and demos:
I am sure I will watch them multiple times. I also hope we get more documentation, more tutorials, and maybe even more WWDC-like videos from Apple. I feel like what we saw in sessions at WWDC and in the tutorials only scratch the surface of SwiftUI.
How Does It Feel?
I don’t have enough experience with the framework yet to declare that SwiftUI is the shortest path to great apps.
But I’m sure having a blast playing with it!
I haven’t felt a sense of joy and exuberance like this about UI programming for a very long time.
Will that sense of joy fade as I start trying to use SwiftUI for a ‘real app’?
Certainly the excitement of novelty will fade as it becomes more familiar. For other aspects, time will tell, but for now I’m just going to enjoy the ride.
For me, there’s joy is in how quickly you can compose a complex view—even a live data-driven view—without much code at all. There’s joy in the tooling and preview mechanism, which is flexible and fairly responsive.
And there’s joy in the fact that the views that you compose are well-behaved.
All those things that may have caused you to breathe a tired sigh in the past—things you knew you should or must support, like Dynamic Type, Right-to-Left UIs, Dark Mode and more—now happen automatically and correctly.*
The framework and tools seem to be very thoughtfully designed, in terms of the functionality that is provided, but also in the unified way that things fit together, scaling from structural components like navigation to views and controls, all the way down to shapes, paths, and graphics operations.
Yesterday, I posted a meme that seems to have gotten a few amused smiles:
I used SwiftUI to compose the meme and have posted the MemeMaker project on GitHub.
Meme Maker is a not-particularly-functional app created by someone on their couple of days using a new technology:
- You can’t edit the text except by editing the code
- You can’t different image unless add other images to the project
- You can’t export or share the meme
The app composes some text over an image in a few different ways and then you can take a screenshot of the result to share if you want to.
But it also shows a few things people might find interesting:
- The main list uses AnyView to pass destination view into row
- The Overlay example uses the overlay modifier to overlay the text on top of the image. Probably the cleanest solution
- The ZStack example shows my original example using nested zstacks to pin text to top and bottom of image
- The Text Gone Wild example shows what happens when the text is allowed to spread out as far as it can
- All examples show using a named font instead of a semantic font
- All examples show adding a shadow to text and using a non-named color
So, I put it out there if you want to check it out.
Feel free to download it or fork it and use it as a starting point for your own explorations. If you discover alternate ways to achieve the same result or any other cool things, let me know at @jamesdempsey at Micro.blog or Twitter. •
I’m also trying to post a record of feedback I’ve filed. If anything sounds good to you feel free to file similar feedback.
FB6145912 Would love an ‘Embed In…’ menu option when writing SwiftUI code
FB6145990 Would be great to have option to refactor a View directly into a new SwiftUI file
FB6139401 Framework Reference docs should include a Symbol Index Oh how I miss having that big, high info density index of Class / Struct / Protocol / Function symbols!
*And you didn’t breathe that heavy sigh because you didn’t want your app to have that functionality—it was because it takes a chunk of time and work to do and do correctly—time you wish you could spend improving the core functionality of your app or maybe even spending with family and friends. ⏎
Categories: Apple, Software Development, iOS