Swift Evolution

Concurrency just got a whole lot easier

programming symbol
programming symbol

A lot of the code we write has to deal with asynchronous behaviour. Fetching data from the disk, sending a request to a remote API, or downloading an image — all these operations take time, even on your super-fast, low-latency working-from-home network.

A simple way of dealing with this is to just wait until a call has finished and the data we requested has arrived. The problem with this approach is that your app’s UI will freeze while it’s waiting. We’ve all used apps that seem to completely freeze up for certain tasks — it’s a terrible user experience.

So…


👋🏻 Hello everyone!

As we’re on the final stretch of this year, we, the Firebase team, wanted to take a moment to reflect on the past year and express our gratitude to you, our readers and authors!

This year has turned out to be unlike any other, and I am sure many of us had to go through some difficult times. Despite all this, you’ve continued to amaze us with your resilience and creativity. At Firebase, we love to read about all the ways you use the tools and SDKs we provide. …


Image for post
Image for post

Firebase Authentication

Replicating the iOS Reminders App, Part 4

This article is part of a series of articles that explores building a real-world application using SwiftUI, Firebase, and a couple of other technologies.

Here are the previous parts of the series:

At the end of part 3, we briefly touched on an issue that users who sign in to the app on a secondary device might face:

You might think that using an app on two different devices should be an entirely reasonable thing to do. Still, when trying to sign-in on the second device, Firebase will return an error message saying

“This credential is already associated with a…


👋🏻 Hello everyone!

We’re well into the final quarter of the year, and we wanted to send a quick roundup of some of our favourite articles we’ve published in the past three months.

We’ve had an amazing quarter here in Firebase Developers on Medium — thanks to all the great contributions many of you have sent us!

Enjoy!

Peter Friese
Developer Advocate, Firebase

👥 From the community

When we started this publication, one of our main goals was to foster a community of people who are passionate about Firebase, and love to share their knowledge. We are extremely happy to see that — thanks to you! —…


Goodbye AppDelegate

An illustration of a rocket circling around the Earth.
An illustration of a rocket circling around the Earth.

For the longest time, iOS developers have used AppDelegate as the main entry point for their applications. With the launch of SwiftUI2 at WWDC 2020, Apple has introduced a new application life cycle that (almost) completely does away with AppDelegate, making way for a DSL-like approach.

In this article, I’ll discuss why this change was introduced and how you can make use of the new life cycle in new or existing apps.

Specifying the Application Entry Point

One of the first questions we need to answer is “How can we tell the compiler about the entry point to our application?”


SwiftUI 2

Image for post
Image for post

For the longest time, iOS developers have used UIApplicationDelegate to handle application startup and other lifecycle events in their apps. At WWDC 2020, Apple made some significant changes to how apps participate in the application lifecycle.

In this article, we’re going to take a look at what this means for your Firebase apps. For a more in-depth look at the new application lifecycle, check out this other article I wrote recently:

When you create a new SwiftUI app in Xcode, you will notice there are no AppDelegate or SceneDelegate classes any more. …


Application Architecture for SwiftUI & Firebase

In this series of articles about SwiftUI and Firebase, we’re building a simple CRUD (Create, Read, Update, Delete) application that allows users to manage their book library.

Image for post
Image for post

In previous episodes,

The following screen flow diagram gives you an impression of what we’ve achieved so far (in the blue frame):


Get those important strings out of your code and into PLIST files

Image for post
Image for post

Many APIs require developers to provide an API key and/or API secret to be able to access the API.

This is both to identify the app that is accessing the API and to limit access to the API for apps that are known to the API.

Both the API key and the secret (if you have one) should be treated as a secret: Anyone who knows these can access and use the API, impersonating your app. This results in all sorts of security concerns: Depending on the type of API, an attacker might be able to access your application’s data…


Application Architecture for SwiftUI & Firebase

Image for post
Image for post

Previously in this series of articles about SwiftUI and Firebase, we talked about fetching data from Cloud Firestore and how to map from Firestore documents to Swift structs using Swift’s Codable API.

You might recall that we also introduced a way to add new books to our collection of books in Firestore. To do so, we added a method addBook(book:) to our view model. However, we didn't actually use it, as we didn't have a UI in place for entering the details about the new book.

So today, let’s look at how to build UI for adding a new book…


Application Architecture for SwiftUI & Firebase

Learn how to easily map Firestore data in Swift

Image for post
Image for post

Last time, we looked at how to connect a SwiftUI app to a Firebase project and synchronise data in real time. If you take a look at the code we used for mapping from Firestore documents to our Swift model structs, you will notice that is has a number of issues:

  • It is rather verbose — even for just the few attributes we’ve got!
  • The code makes some assumptions about the structure of the documents, such as the attribute types
  • Things might start breaking if we change the structure of…

Peter Friese

Google Developer Advocate with the Firebase team 🔥

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