Jan Kaltoun3 min

Swiftly Highlights Ft. Property Wrappers, Swift 5.6 & More

EngineeringApr 5, 2022

Engineering

/

Apr 5, 2022

Jan KaltounChief Technology Officer

Share this article

Hello and welcome to the latest installment of Swiftly Highlights — your monthly dose of all things Swifty! There’s plenty to talk about today, so let’s dive right in.

Property Wrappers

Property wrappers can be hard to wrap your head around, and every tutorial is a blessing. Handling view state can sometimes be no less confusing. Take a look at how to (not) initialize @State inside the View's init by Valentin Radu to get an in-depth explanation about dynamic properties and what’s going on when you use the magical underscored variants of your wrapped properties.

Once you’ve digested the @State wisdom, make sure to take a peek at Antoine’s article explaining @published risks and usage — with code examples.

Swift (5.6)

Did you notice that Swift 5.6 is out? As with every release, Paul Hudson has prepared a handy summary of what’s new in this version of our beloved language. And there’s a lot!

We now have a new keyword — any — that we should start using to mark existential types. As Paul remarks: this might sound a bit esoteric and if you find it as such, make sure to read his explanation! If you want even more information, check out Donny’s article What Is the “any” Keyword in Swift? and Antoine’s post disambiguating all the [Aa]ny*s - AnyObject, Any, and any: When To Use Which?

Swift Concurrency also continues to be refined in Swift 5.6, in particular by SE-0337 - Incremental Migration to Concurrency Checking and SE-0327 - On Actors and Initialization. You may have noticed that, in the latest Xcode, you started getting warnings when initializing your @StateObject properties out of the view initializers when those Observable Objects are marked as @MainActor. Paul offers the only possible solution that (as he remarks) actually goes against Apple’s own documentation. Swift Concurrency is obviously still going through changes and it remains to be seen what the final solution to this warning will be!

There are a bunch more changes definitely worth your attention, all handily described in Paul’s article.

SwiftUI (and a Touch of UIKit)

Have you ever heard about SwiftUI’s Canvas? If not, head over to Better Performance With Canvas in SwiftUI by Eric Callanan to play with cards and learn how Canvas can save the day when performance issues arise.

In iOS, we like to live on the edge. We’re never sure when the system will kill your app after the user leaves it. When that happens, the entire app state is lost by default — which does not lead to the best user experience. Fortunately, State restoration is possible and Majid tells us all about implementing state restoration in SwiftUI.

SwiftUI is at its third iteration at this point and UIKit still hasn’t gone anywhere (and is not going anywhere, in my opinion). You may miss some SwiftUI features while developing using UIKit, though — for instance, the Previews. In his article titled Using Xcode Previews for UIKit, Jordan shows you how to get previews for your UIKit code, too!

Assorted Swiftly Highlights

A new version of RocketSim — the tool enhancing your iOS Simulator capabilities — is out and you can read all about it in Antoine’s announcement! Give it a try, I promise that it definitely will step up your Simulator game!

Accessibility is a topic that every engineer — not just on Apple platforms — should care about. This month, John Sundell invited Sommer Panage to chat (not only) about a11y in his podcast and it is absolutely worth a listen.

Last but not least, there were two important messages from Apple. Firstly, the App Store submission requirement starts April 25th and it mandates that all iOS, iPadOS and watchOS apps submitted to the App Store must be built with Xcode 13. Secondly, there have been some interesting developments in the App Store Review Guidelines. Head over to Apple’s announcement to find out more about how “reader” apps can now provide a link to their website, where people can create and manage their accounts by requesting the External Link Account Entitlement.

That’s it for March! Thank you for reading and see you next time!

Share this article



Sign up to our newsletter

Monthly updates, real stuff, our views. No BS.