Swift Developments is a hand-curated newsletter containing a weekly selection of the best links, videos, tools and tutorials for people interested in designing and developing their own apps using Swift.
Hi and welcome to Swift Developments Issue 197! So it’s sounding like September 10th is going to bring us the next round of Apple hardware announcements. For me, I’m less interested in the phones this year and *much* more interested in where Apple have got with the next generation of MacBook Pro. With my ageing 2012 MBP starting to show it’s age and a 16-inch MBP rumoured, it might be time for a new one so I’m interested to see what they announce. ?
In this three-part series (Part 1, Part 2, Part 3) Davide Lorenzi explains how the team at @transferwise are using Flows to structure, organise and coordinate their view controllers, to add flexibility and customizability to their app and to build larger-scale components that can be easily reasoned about.
Introduced in Swift 5.1 via SE-0261, the new
Identifiable protocol provides a stable mechanism for identifying entities. In another great article, @mattt digs into why
Identifiable is important and how it relates to its sibling protocols
Hashable before moving on to provide some examples of where you might want to use it in your own code.
If I’m honest, I’ve not yet made a concerted effort to get up the Combine learning curve. With that said, it’s in the plan for the next few months so I’ve been keeping an eye out for useful resources that will help ease that journey. With that in mind, this article from @V8tr caught my eye which provides a nice introduction to some of the key components if you’ve never really played with any of Swift’s existing reactive frameworks before.
PDFs provide a great way of bridging the gap between online and printable documents. In this step-by-step tutorial, @bmorefield shows you how to create PDFs of your own using PDFKit – a framework introduced in iOS 11 that provides the ability to display, create and manipulate PDF documents from code.
@M0rtyMerr with a simple explanation of how to write unit test cases to guarantee that your RxSwift code doesn’t contain any memory leaks. It’s a surprisingly simple technique but a great way to ensure no nasty out-of-memory errors appear in your future.
I liked this article from @xtabbas. It has some great observations about SwiftUI, both in terms of its current state, and some of the pitfalls if you’re just getting started. The biggest thing I agreed with is that putting aside all the hype, SwiftUI is something that you really have to try for yourself to understand what it has to offer. Although Apple has done a great job with it so far, it’s still really new (and still changing) so for side projects, experiments or even, maybe at a push, a brand new app, it might make sense, but for me, it’s going to take some time before it reaches a level of maturity needed to become the de facto choice for a production app. It doesn’t mean I’m not going to be experimenting in the meantime though! ?
View modifiers are an important concept in SwiftUI allowing you to transform existing views or view modifiers and create a new different version of the original value. Whilst SwiftUI has an ever-growing number of view modifiers built-in, it’s also possible to build your own, something that @sarunw walks you through in this article.
Caching can be a great way to improve the performance of your app. This week @AndyIbanezK has written a great introduction to Apple’s in-memory solution
NSCache covering everything from adding and removing objects from the cache through to the
NSDiscardableContent protocol and automatic cache eviction. Coincidentally, @johnsundell has also covered caching as well this week so once you’ve read Andy’s article, make sure you check out John’s article as well.
It can sometimes be difficult to see the link between ML tutorials and their application in a real-world app. Not so with this tutorial from @omarmhaimdat that uses Swift, CoreML and Turi Create to detect whether construction workers are wearing their safety equipment.
One huge, and extremely powerful feature added in iOS 13 this year is Voice Control allowing users to navigate user interfaces with just their voice. I’ve tried it myself not long after it was released and was surprised how powerful it actually is. If you’re looking to implement support for this in your own apps (you really should be), check out this article from @krstnfx which provides some useful tips on how to get started.
Back at the start of August, GitHub introduced a new CI / CD feature called GitHub actions – a way to orchestrate workflows based on different events in your repository. @iosartem has been taking a look and covers some of the pros and cons of using GitHub actions for Swift projects.
Level up your debugging skills with this in-depth video tutorial from @LucasDerraugh looking at Xcode’s Memory Graph debugger – a powerful way to examine memory allocations in your app and catch and debug retain cycles.
One of the more complicated aspects of SwiftUI is how data can be passed between different views. In this tutorial @brianadventcode takes a look at the concepts of State, ObservableObject and EnvironmentObject and how you can use them to share data between views in your app.