With Apple announcing WWDC week for June 6–10 this yr, let’s dive into what new frameworks, APIs, and instruments I hope to see unveiled and what utilizing them would possibly really feel like with examples.
Annually, there’s this very particular time, when a particular group of individuals is making needs and getting their hopes up for all kinds of issues. Some share their wishes with others, some simply maintain them secret of their heads to not get too disenchanted if not fulfilled. I was within the latter group, however this time I’d prefer to share my needs to enhance the chance of them coming true — if not this yr, then possibly the subsequent. In any case, Santa may be listening.
I’m going to skip any of the plain matters which can be on prime of just about each iOS developer’s checklist, reminiscent of a extra steady Xcode, a extra bug-free Swift, a extra full SwiftUI, or extra dependable SwiftUI Previews. Let’s get began!
Each app is required to have an app icon. Xcode requires us to supply the app icon in dozens of various sizes although, with none help to resize them. Whereas there are numerous apps & instruments to assist get there, just a few of them help the newest set of sizes as Apple likes so as to add new sizes over time. That is an pointless impediment for brand spanking new builders simply beginning.
When dragging & dropping a 1024×1024 picture to the
AppIcon set or the
App Retailer entry within it, Xcode ought to ask us if we need to use this as a reference picture to generate all different sizes from. The identical may additionally occur when dragging & dropping an SVG file, though I might already be pleased with the 1024x sizes one.
An alternative choice to drag & drop could possibly be an possibility on the best pane when choosing the
AppIcon picture set named one thing like “Generate sizes on archive” so that you all the time solely want to supply and even commit one measurement and Xcode would generate the others on the fly when archiving for a launch.
.xcassets had been launched alongside Xcode 5 in 2013. They haven’t obtained a lot love since then, so I doubt that is ever coming. However, Swift Playgrounds on the iPad does appear to have the ability to generate all sizes from only one “picture”. Whereas this would possibly technically work with vector graphics, possibly we would see this very same icon generator in Xcode someday?
Working in app targets with numerous recordsdata which can be grouped in folders to loosely signify options that belong collectively is straightforward however has its drawbacks. For instance, to check out the smallest code change, you want to construct your entire undertaking. This additionally comes with SwiftUI previews working much less reliably or simply taking very lengthy to point out your modifications. Whereas incremental builds aren’t that gradual, in apply you do make modifications somewhere else too after which Xcode has to construct greater than wanted. Otherwise you’re explicitly telling Xcode to make a clear construct as a result of, properly, by some means Xcode doesn’t behave as anticipated.
However construct occasions aren’t the one downside of a single-target undertaking. Having all of your sorts in a single
important module means that you’ve entry to every type from all over the place as a result of Swift defaults to the
inside entry degree — this isn’t good because it might make your code more durable to reuse and take a look at. And even when you wished to mark all of your properties & features explicitly with a decrease entry degree, you may’t use
fileprivate as quickly as it’s important to entry them from only one different file — it’s additionally simple to neglect so as to add these.
The present workaround I personally use is defined by Stephen and Brandon from Level-Free in this video intimately. Whereas it fixes each the above issues, it’s a trouble to maintain the
Package deal.swift file up to date manually. Simply take a look at this manifest file of my (at the moment) one-screen solely Focus Timer app.
Apple might present a brand new UI inside Xcode that enables for creating packages for our app’s modules with out having to do any workarounds like talked about above. I believe the simplest means to do that is so as to add help to the present “targets” UI, however with an additional part for Swift packages and with SwiftPM because the underlying know-how. Additionally, at any time when I might reference a sort from a module, Xcode might warn me that I’m accessing an inaccessible module and ask me if I wished so as to add it as a dependency to the present module.
This might even go thus far that Xcode would possibly ask us if we need to create an Xcode project-based app or a SwiftPM based mostly one. Whereas I don’t anticipate (or request) a full substitute of the
.xcodeproj file with a
Package deal.swift file this yr (there’s nonetheless some work to be done in SwiftPM for that, like including construct scripts, and many others.), I believe it’s doable to not less than migrate over the linking of packages to a SwiftPM based mostly basis.
As a lot as I’d prefer to see this yr, I believe Apple isn’t going to do a lot on this course till SwiftPM is able to totally change
.xcodeproj recordsdata. I believe they’re “all or nothing” on this space, so I don’t have my hopes up for this yr. However possibly subsequent yr with a beta flag to choose into?
Core Information was launched by Apple in 2005 alongside Mac OS X 10.4 Tiger as a means to supply builders a nicer API than utilizing SQL directives. Shortly it grew to become the go-to database framework for native app growth, and it nonetheless is. However it was written for Goal-C, clearly. Simply take a look at this straightforward mannequin:
Notice that every one these fields are specified to be non-optional in Core Data:
However they’re all generated as
Optionally available sorts in Swift code anyhow. This and the entire
NSManagedObjectContext API design feels fairly outdated and never very “Swifty” (as in “not secure”). It’s time for one thing new!
Apple might introduce a brand new Swift-only framework (like
SwiftUI) named one thing like
SwiftData which offers a high-level API to outline and handle persistable fashions. Defining a mannequin might look one thing like this:
For fashions to retailer in iCloud, you’d must prepend
distributed in entrance of
actor. Usually accessing any property of an
actor would require the
await key phrase, however some magic property wrappers might simplify this to:
And writing to an
actor property isn’t doable from exterior, however the
@Persevered property wrapper may need some
Binding magic to permit this:
I’ve to confess, I’ve not used Actors in apply but, so forgive me if a few of the above examples don’t make any sense. However I’ve a sense that Actors might play an essential position in a
SwiftData framework for secure entry.
Moreover, Xcode might include a UI that makes it simple to model knowledge fashions and supply a graphical migration device that could possibly be written in a declarative Swift syntax and be previewed as a UML diagram on the best (like SwiftUI previews). However possibly I began dreaming too huge right here …
Many had been anticipating this already for the final two years as a result of it’s a logical subsequent step after SwiftUI. However this yr, with Actors already shipped in Swift 5.5 and Distributed Actors (for iCloud help) being accepted only recently as properly, the know-how would possibly simply be able to ship the primary model by September.
There are many issues Apple might announce in June, and the above are simply my private needs. However previously, I used to be all the time stunned by not less than one or two frameworks fully, like SwiftUI in 2019, WidgetKit in 2020, and DocC in 2021. What’s going to it’s this yr? I can’t wait to search out out!
Notice: The 2nd a part of my “Streaming on Twitch” series is postponed to subsequent week.