Weekly note ✏️
Welcome to our new redesigned and updated newsletter! This is Anton with weekly thoughts. We are on a big transition and the whole format is reshaping, that’s why it’s hard to predict what exactly will thrill the readers. But every journey starts with a first step!
This week, I focused on MapKit for SwiftUI. This framework had been eagerly anticipated for years, as it previously required creating wrappers for UIKit’s MKMapView. Thankfully, Apple announced its native SwiftUI support at WWDC23, making it much easier to build location-centric apps with significantly less code.
As you know, APIs are constantly evolving, sometimes through deprecations, new features, or removed functionality. In iOS 17, a year after the initial announcement, MapKit transitioned from a coordinates-centric model to a camera-centric one. This means we now manipulate the camera and pass coordinates to it, instead of directly interacting with the Map. The same principle applies to managing regions and user location, which is now handled via the UserAnnotation.
This shift reminds us that in today’s fast-changing tech landscape, it’s essential to stay informed about what’s possible and dive deep into the details during implementation.
Sponsor 🤝
Scale up your snapshot tests, without the friction
Spending too much time maintaining snapshot tests? Screenshotbot works with your existing snapshot tests and stores your images. Say goodbye to Git LFS. Screenshotbot notifies you on pull-requests when snapshots change.
Swift Around the Web 🌐
Adopting Swift 6 across the app codebase
Learn about the benefits of Swift 6 for data security. To avoid data races, it recommends using structs over classes. Classes are still useful for managing shared states, especially in view models or with global actors. Read more.📍
Understanding opaque types and protocols with associatedtype in Swift
Learn how to simplify the process of working with protocols associated with types by using opaque types, represented by the some keyword in Swift. Opaque types offer a cleaner alternative to generics, enhancing code readability and maintainability. The post illustrates how to use opaque types in function parameters and return types effectively. Read more.📍
Coding 👨💻
Codable conformance for Swift enums
Learn how to make Swift enums Codable, enabling them to be serialized and deserialized for working with data formats like JSON.
This post explains automatic conformance for different enum types and covers customization techniques, such as mapping case names and associated value keys. It also discusses custom Codable conformance for complex scenarios. Read more.📍
Swift Parameterized Testing
Learn how to use parameterized testing in Swift Testing. It demonstrates how to use this feature with single and multiple arguments, including using zip to combine them.
This post highlights the benefits of parameterized testing, such as improved test readability and the ability to easily rerun individual failing test cases. Read more.📍
Xcode 16's Buildable Folders
Explore Xcode 16's new buildable folders feature, eliminating the need for pbxproj file references. This simplifies project management by reducing merge conflicts.
The author describes the adoption process and highlights the removal of over 100 unused Swift files and a significant reduction in the size of the pbxproj file. Read more.📍
Apple News 🍏
iOS & iPadOS 18.3 Beta 2 Now Available
Developers can update to the iOS & iPadOS 18.3 Beta 2 SDK, bundled with Xcode 16.2, to test their apps against the latest API changes and incorporate new features. Key fixes include Genmoji generation, HealthKit authorization, and Writing Tools API issues. Read more.📍
Design 🎨
Enhance UI/UX with the confirmation dialog component
Learn to use the `confirmationDialog` component in SwiftUI to create confirmation dialogs. These dialogs help users confirm actions, choose options, and cancel operations. It details the parameters used with `confirmationDialog` and includes a code example demonstrating its integration into a SwiftUI view. Read more.📍
Other cool stuff 🧰
Testing Background Uploads in iOS
This post refines recommendations for testing background uploads in iOS. It clarifies that invalidating `URLSession.shared` has no effect and that invalidating the background `URLSession` requires relaunching the app.
It also corrects the recommendation to use `exit(0)` in `applicationDidEnterBackground(_:)` for apps using scenes, suggesting the use of `sceneDidEnterBackground(_ scene: UIScene)` instead. Read more.📍
Creating tiny utility apps with SwiftUI Previews
Explore a technique for creating tiny utility apps using SwiftUI package internal views. Xcode can run these apps directly, reducing development time. The post demonstrates this technique with an example of a "Locale Explorer" app used with the KeyboardKit project. Read more.📍
Markdown links can do what?
Discover how SwiftUI's Markdown links can be used for more than just linking to web addresses. By leveraging custom URL schemes, you can create interactive elements within your app.These elements can trigger actions such as logging, custom functionality, or even animations. Read more.📍
AI 🤖
OpenHands
OpenHands (formerly OpenDevin), a freshly launched open-source tool, is poised to redefine how developers tackle repetitive and intricate tasks. It handles everything from tweaking code to running commands and navigating APIs. Tool is already highly supported by community. Read more.📍
Tutorials 📒
The Power of Protocols in Swift
A comprehensive overview of protocols in Swift. It covers key concepts like protocol definition, inheritance, composition, extensions, and generics. The article discusses the benefits of protocols, such as flexibility and reusability, and demonstrates their practical applications in real-world scenarios, including dependency injection, UI component design, and networking. Read more.📍
Video 🎥
Interactive SwiftUI Chart - Drag to Show Data w/ Animation
This video demonstrates how to add interactive elements to a Swift Charts bar chart. By using the chartXSelection modifier, you can enable users to drag along the chart and display relevant data in an annotation view.
Sean Allen tries to cover key steps like matching data to the selection, building the UI, and implementing the lollipop annotation view, providing a practical guide to enhancing the user experience of your Swift Charts. Watch the video.📍
Books/Freebies 📚
iOSDevKit - Cheat Sheets, Posters & Infographics
"iOSDevKit" offers a collection of high-quality cheat sheets, posters, and infographics designed to help iOS developers of all levels. It covers essential topics like Xcode, SwiftUI, and iOS development concepts, providing concise and visually appealing resources to improve learning and productivity.
Free and paid options are available. Download here.📍