It looks like April was an important milestone for Apple. There was a “Spring Loaded” event on April 20th (4/20) that announced multiple new things, like colorful iMacs, the long-awaited AirTags and an upgraded iPad Pro with the amazing M1 chip. But Apple didn’t stop there. iOS/iPadOS 14.5 was also released and with it some major privacy changes which we’d been expecting since last year’s announcement, and which led to heated discussions throughout the industry.
Developers need to make sure that their apps comply with the new rules and follow Apple's guidelines, which are now updated to include rules on how developers should ask for privacy permissions. Make sure you follow the rules; Apple doesn’t like when you don't—something Epic Games learned the hard way. If you’d like to know more about the implementation of some of those rules, the Swift Senpai’s got you covered.
Another much-anticipated event happened, and that’s the release of Xcode 12.5—which includes some interesting improvements that might make writing code even more fun and, most notably, the new Swift 5.4. Might someone have thoughts on this? Yep, you guessed it! Of course Paul Hudson has an article ready.
It seems like there won’t be a single month when SwiftUI or Combine don’t produce any interesting ideas and solutions. So, let’s start with Combine.
If you literally want to start with Combine, John Sundell has a new great page called Discover and one of the topics is Combine. You can also read a slightly less profound but still amazing post by Antoine van der Lee.
As you introduce Combine into your codebase more and more, you’ll probably stumble upon how to make other parts of your code compatible with Combine. Majid shows a simple approach on how to wrap existing API and convert it into a Publisher. If you are already familiar with Futures from our March edition, you can find out why it might not always be a good idea to use them. You’ll also learn how to read files with Combine.
It seems like SwiftUI is slowly creeping its way into production and one of the adopters is an SDK for working with PDFs, called PSPDFKit. Peter Steinberger mentions (also includes a video presentation) that although it was a challenging experiment, they’ve found workarounds for some SwiftUI limitations, especially the SwiftUI Version 1. Alex Grebenyuk took a different approach and build an entire app, called Pulse in SwiftUI. He describes the positive aspects and what could be improved in the next versions of SwiftUI (fingers crossed for the upcoming WWDC).
You might not understand everything in the posts above, in which case this extensive article on every SwiftUI protocol might help you. Or you can check out some SwiftUI notes and resources from Jesse Squires.
Alternatively, if you’re fluent in SwiftUI, you can check out this post about conditional modifiers, which could help reduce unnecessary if / else statements.
Apart from the Swift 5.4 release mentioned in the beginning, Swift also released a new package called Swift Collections. This might prove useful if you work with big data structures and need to optimize for performance.
Even though many of us work with Swift daily, we still learn new things all the time. Most recently, we learned about why exactly we can’t easily compare beloved Swift Closures.
Have you ever used an app that was showing weird units or dates? It might have been because the developer didn’t use a Formatter. There are a lot of different formatters; you can find some lesser-known formatters that might still be very useful.
That’s it. Hope you learned something new. See you next time!