Let me first say: I think it’s hilarious Apple didn’t even mention augmented reality this year. On one hand, it felt like very purposeful trolling; on the other hand, much of Apple’s unusually straightforward messaging this year was clearly designed to prepare developers for new form factors (larger iPads? AR/VR headset?).
During the Platforms State of the Union, Josh Shaffer (Senior Director, Swift Frameworks) gave an overview of Apple’s overall platform vision. He concluded with this statement, directed toward anyone creating a new app in 2022: “The best way to build an app is with Swift and SwiftUI.” Throughout the week, in both sessions and digital lounges, engineers from various teams continued to expand on that statement, reminding developers that AppKit and UIKit weren’t going anywhere.
For example, in the SwiftUI Digital Lounge, SwiftUI engineer Taylor Kelly wrote the following:
“Across all platforms, we’d recommend comparing your needs to what SwiftUI provides (so no hard rules/recommendations) — and keeping in mind that you can adopt SwiftUI incrementally.
Within Apple’s own apps on macOS, we’re ourselves using the full spectrum of approaches. From just a specific view/views in an app, e.g. in Mail, iWork, Keychain Access; to an entire portion of the UI or a new feature, e.g. in Notes, Photos, Xcode; and all the way to the majority of an application, e.g. Control Center, Font Book, System Settings.
But in the end, I’d recommend starting with a part you’re comfortable with and building up from there! You should look at SwiftUI as another tool in your toolset in enabling you to build the best apps you can. [emphasis added]”
One of the most important things Apple did during this year’s WWDC was untangle the mess of code paths for making a Mac app. Instead of native SwiftUI, pure AppKit, SwiftUI + Catalyst, and UIKit + Catalyst, we have the following:
- SwiftUI only, if you’re starting with an iOS app written primarily in SwiftUI. UIKit and/or AppKit can be sprinkled in as needed.
- UIKit + Catalyst, if you’re starting with an iOS app built primarily using UIKit. SwiftUI can be sprinkled in as desired.
- Pure AppKit. SwiftUI can be sprinkled in as desired.
SwiftUI gained some significant improvements this year in the areas of navigation, UI layout, and system integration (i.e. photo picker, share sheet). With these additions, my iOS 16 update for YarnBuddy should put it on par with what it would have been if I’d built it using UIKit. I know that sounds nuts, but that’s early adopter life! If you don’t need to support older OSes, this is the right time to jump into SwiftUI.
I was probably one of only a few people that let out an audible squeak of excitement when “What’s New in PDFKit” appeared in the session schedule. With a new API for adding a PencilKit overlay to PDF pages, I can replace my incredibly hacky PDFKit/PencilKit implementation (involving syncing up zooming and scrolling between a PencilKit canvas and a PDFDocument…ugh) with something that should work much smoother. ?
While the sessions are always really helpful, I came across a few things while browsing sample code and the SwiftUI Digital Lounge that I wanted to share here, in case they help you too.
I’m not sure why this wasn’t added as a built-in option, but if you’re planning to use SwiftUI’s new Layout protocol to create your own horizontal flow layout (e.g. a cluster of tags), you don’t need to reinvent the wheel. A FlowLayout is included in the new Food Truck sample app, and you can find it on GitHub.
Core Data + CloudKit
Apple has just updated Synchronizing a local store to the cloud to include some code for testing and debugging NSPersistentCloudKitContainer implementations. I’m also planning to copy Apple’s clever implementation of thumbnail caching for images stored in Core Data. I’m assuming this sample project is considered best practice, so it’s probably a good idea to take as much from it as possible.
Changing view presentation style based on size class in SwiftUI
This was possible pre-iOS 16, but I only just realized it after someone asked in the SwiftUI Digital Lounge. If you’d like to present a view as a sheet in one size class and a popover in another, you can do that by creating a view modifier that looks at the UserInterfaceSizeClass. I haven’t checked this out myself, but apparently you can find an example of this use case in the Bringing multiple windows to your SwiftUI app sample code, in ProgressEditor.swift.
As an Apple product owner, there were several things that really caught my attention. The first was Shared iCloud Photo Libraries. My husband and I often AirDrop each other photos so that we can each have them in our libraries. We also have Shared Albums set up with each of our kids so they can see some of the photos we take on their own devices. Shared iCloud Photo Libraries will finally eliminate all of that needless sharing and shuffling.
The new Shortcuts APIs also look really promising to me. If apps can pre-bundle shortcuts that will automatically appear, that will drastically increase my use of them. Currently, I don’t have the time or patience to piece together my own shortcuts, even though I know they could end up saving me time.
Other things I’m looking forward to include improved sleep metrics on Apple Watch, new Lock Screen customizations, Messages editing and mark-as-unread, improved Mail search, and Stage Manager for iPad—although I won’t get to experience that until I upgrade to a future M2 iPad Pro.
Finally: Weather for iPad. Having the widget without the app was ridiculous, and I’m glad we can put that embarrassing situation behind us.
My plan this summer is to finish up a quick pre-iOS 16 update for YarnBuddy that allows crochet and knitting projects to be exported as PDFs. Then, I’m going to more or less rewrite the app for iOS 16, adding in as many of the new goodies as I can. I plan to keep my old views around in a different code path so I can continue supporting iOS 14 & 15 though. My question for all of you is: what percentage of active devices (or sessions) serves as your threshold when deciding whether or not to drop support for an older OS version?
Anyway, YarnBuddy 2.0 will be available this fall, for iOS, watchOS, iPadOS and, for the first time, macOS. I’m hoping by the end of this year I’ll hit 500 subscribers, which is a pretty cool milestone to look forward to. Best of luck to all of you working on app updates (or brand new apps!) over the next few months!