👷 Refactoring my SwiftUI Navigation Layer to follow the Coordinator Pattern 🔀
Welcome to the issue #22 of the iOS Coffee Break Newsletter 📬.
I strongly support a clear separation of concerns for a clean design pattern, and in my experience, separating navigation logic from views is essential for scalability. Recently, I implemented a navigation layer for my SwiftUI apps, initially handling only stacked screen navigation. I left out sheet and full-screen presentations, planning to add them later.
So, this week, I published an article on refactoring my navigation layer to handle additional presentation types, enabling more versatile navigation. I transitioned from a Router to a Coordinator model and the picture below illustrates how I can navigate the app after the update.
The main objective was to transition from a linear navigation stack to a distinct set of independent navigation screens using a sheet presentation. Here is a quick demo from the sample project I have set up:
My initial Router setup handled navigation for a single screen, while my updated Coordinator-based navigation layer supports nesting, with parent Coordinators managing child Coordinators to enable complex hierarchical navigation flows throughout the app.
If you have thoughts or personal experiences with SwiftUI navigation, I would love to hear them — feel free to reach out to me on Twitter!
If you are only interested in the code, here is the GitHub repository.
Now it is time to dive into some iOS development topics submitted by the community. Here are this week's highlighted resources. Hope you enjoy 🙌.
💡 Automate GitHub Tasks with GitHub CLI in Actions Workflows: A Step-by-Step Guide
Did you know that GitHub-hosted runners come with the GitHub CLI pre-installed? I wasn't aware either! By combining the GitHub CLI with GitHub Actions workflows, you can streamline tasks that typically require manual effort.
Pol's latest article dives into using the GitHub CLI with the provided token in workflows to automate tasks like creating pull requests or managing issues, reducing friction and improving efficiency.
✨ Preview SwiftUI views with bindings using @Previewable
Starting with Xcode 16, the new Previewable macro simplifies previewing SwiftUI views that use bindings.
Natalia's recent post offers a quick guide on how to apply it. This addition is highly practical, as it allows for fully interactive previews without needing to embed state within child views, streamlining the preview process.
🤯 GitHub Copilot for Xcode Uses TCA!
Recently, GitHub launched GitHub Copilot for Xcode, an extension designed to simplify using their AI assistant directly within Xcode.
In a post, Romain pointed out that this new extension runs with TCA (The Composable Architecture), making it even more appealing to developers who rely on this library. It is exciting to see increasing adoption of Point-Free's composable architecture by individuals and companies alike. What are your thoughts on TCA and its growing popularity?
✍️ Mastering TextEditor in SwiftUI: Features, Limitations, and Tips
Artem's latest article dives into the fundamentals of TextEditor in SwiftUI and demonstrates how to enhance it with added features.
This is the first article in a series focusing on text editing. Upcoming articles will delve into topics like text classification and creating custom machine learning models for text analysis. I am super excited to follow along as this series unfolds!