How to sync data between your app running on multiple devices?

Mark van Wijnen
5 min readApr 16, 2023
Photo by Firmbee.com on Unsplash

Introduction

So the idea is to store the data of the app using Core Data and use CloudKit to store this data in the cloud and sync it between the devices.

In this story I will walkthrough the easiest and minimum amount of steps to get this up and running. What you will end up with is an app that is able to create and delete records and you will see it update on all your devices.

If you came here just for the solution you can skip the backstory and go straight to the setup.

Backstory

Let me take you through the process I went through when I first attempted to create this and why I felt I needed to write this story.

If you are like me, you quickly want to see if the tools provided by Apple work. You want to have the app open on the Mac and iPhone and see the data sync between those two platforms with your own eyes. This way you know you have a good foundation to build the rest of your app upon.

So you open Xcode and create a new multiplatform project. Here you will notice a few interesting checkboxes: Use Core Data and Host in CloudKit.

My assumptions were that with both checked Apple will give me a base template that will work out of the box. That I…

--

--

Mark van Wijnen
Mark van Wijnen

Written by Mark van Wijnen

macOS/iPadOS/iOS/watchOS/visionOS developer and SwiftUI enthousiast. “Stay Hungry, Stay Foolish!” — Steve Jobs

Responses (1)