A hands-on implementation of the Locks and Keys design pattern

Photo by Markus Winkler on Unsplash.

When iOS apps begin to grow, we need to handle some kind of global state. The global state usually contains two kinds of information:

Whether the user is logged in or not is metadata. The app can use that information to show the profile page (when the user is logged in) or the login page (if the user needs to log in).


How to create custom templates for yourself and your team in Xcode

Man typing on laptop
Man typing on laptop
Photo by Zan on Unsplash.

Whenever a team grows, it decides to adopt a specific architecture and some specific pattern. It can use MVVM or VIPER. It can use UIKit or SwiftUI. It can use protocol-oriented programming or the Protocol Witness approach. Many of these patterns require some boilerplate that we never enjoy writing.

Any Xcode developer is pretty familiar with the “New File” screen that can be invoked by typing ⌘+N.

A transcription and translation of a PointerPodcast episode

Last week I was invited as a guest to a podcast called PointerPodcast. In that episode, I was asked a few questions about iOS Development and writing technical articles on Medium.

The podcast is in Italian and this is the link to the episode. Therefore, I asked the podcast owners the permission to translate and publish it.

I want to thank Alessandro, Eugenio, and Luca for inviting me and letting me translate the interview. You are doing a great job. Keep it up!

Note: The translation is not a literary translation of the interview. I changed a few words to…

How to define modules for your app using Swift Package Manager

iPhone with colorful screen sitting in front of a keyboard
iPhone with colorful screen sitting in front of a keyboard
Photo by Raagesh C on Unsplash

Back in 2018, during the WWDC, Apple announced the Swift Package Manager (SPM or SwiftPM). The goal of SPM is to allow developers to define modules that can be reused across different applications and platforms. A package could be defined to work with both iOS and macOS, for example, and therefore its features can be shared across tools and apps on those platforms.

In the beginning, the package manager was quite limited: It did not support module-specific resources, for example. During the following years, the SPM has improved a lot. It now allows developers to define executables other than packages…

What happens when a VC is created and presented?

Leaves turning from green to brown
Leaves turning from green to brown
Photo by Tolga Ulkan on Unsplash.

When developing an app, we might need to add some custom logic when a UIView is loaded. For example, we may need to perform a network call to fetch some data from the backend. On other occasions, we may need to clear up some resources when the view is about to be dismissed and hidden from the user.

Although these ideas are simple, there are a few nuances in iOS development. It may be helpful to explore them together.

Note: Even if you are developing only with SwiftUI, you may benefit from this article. SwiftUI views may be loaded into…

How to specify different kinds of arguments and leverage type safety in our CLI apps

Laptop keyboard
Laptop keyboard
Photo by hannah joshua on Unsplash.

Last week, we started a new project where we implemented a very basic calculator application from the command line.

We developed that project to explore the ArgumentParser library provided by Apple that gives us automation to read the input of the user from the standard input.

This week, we will dive deep into some more advanced features. Before starting, I suggest taking a quick look at last week’s code to refresh some concepts.

Validation: Implementing the Div Command

Our app is using the Comand pattern as the main architectural style. Whenever we need to add a new command, we know we have to extend the…

How to create a well-structured CLI application using SPM and the argument parser

close-up of a Mac keyboard
close-up of a Mac keyboard
Photo by Athul Cyriac Ajay on Unsplash

Swift is a well-rounded language, and it is becoming more used every day. Its main usage is for iOS and macOS apps, but it is used also for scripting, command line tools (CLI), and even for backend and web development.

In this article, I’d like to explore a library provided by Apple to create a CLI application: the Swift Argument Parser. This library encapsulates the logic of parsing the input of the user when issuing a command in the Terminal. The library does that by using property wrappers. The Swift’s type system makes everything safe.

Thanks to this library, we…

A great code review boosts code quality and creates a learning environment

People working together at a desk
People working together at a desk
Photo by ThisisEngineering RAEng on Unsplash

For every story, there are always two sides. Last week, we talked about how to prepare a good PR. Today, I’d like to talk about how to perform a good code review.

Code reviews are a very important part of every developer’s day. The two main goals of a code review are to:

Additionally, it happens quite often that the reviewer learns something new in the process of performing the code review. …

Small suggestions to make the life of your reviewer easier

Photo by Markus Winkler on Unsplash.

Creating a PR and waiting for a code review is a standard approach to writing code. PRs and code reviews are very important in every developer’s day. They achieve different goals:

The process is usually split into two steps: A developer prepares a PR and another developer (or several) performs a code review, pointing out the good parts and the parts that can be improved.

Today, I’d like to go through the first step, highlighting how we can create a PR…

How to use concurrentPerform to write parallel code with ease

Photo by Nathana Rebouças on Unsplash.

If you follow my blog, you’ll know that I love concurrent programming. I’m very fascinated by the idea of running different tasks at the same time, collecting the results, and saving a ton of time.

This week, while working on my team's current project, I discovered a new API that I was not aware of: DispatchQueue.concurrentPerform. This small and nice API lets us run batches of work together and will handle all the concurrency for us.

Let’s explore it together.

concurrentPerform in Theory

When working with a new API, the first thing to do is to read its documentation:

“This method implements an…

Riccardo Cipolleschi

Hey there, I’m Riccardo. Senior iOS Engineer at TrueLayer and ex-Spooner. I breathe iOS development: apps and tools. I love to share my knowledge with others.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store