Skip to content
vrhermit

vrhermit

Code & Writing by Joseph Simpson

  • Canvatorium
  • Technical
  • Professional
  • Personal
vrhermit
vrhermit
Code & Writing by Joseph Simpson
Retrospective | Technical

Setting up CloudKit with Core Data

ByJoseph October 31, 2019June 25, 2023
CloudKit • CoreData

This is something I keep forgetting how to do so I’m posting this as a reference for future me and anyone else that finds it helpful.

These instructions assume you have created a new Xcode project with these options.

  • Language: Swift
  • User Interface: SwiftUI
  • Check the box for “Use Core Data”
  • Check the box for “Use CloudKit

This will create some boiler plate Core Data code in the AppDelegate and SceneDelegate.

In the SceneDelete, add this line after creating the context.

context.automaticallyMergesChangesFromParent = true

In Project Settings, select the target and add some entitlements.

  1. iCloud – Add this entitlement and select the “CloudKit” checkbox. Use the default container for your project or select one from the list if you have already created one.
  2. Background Modes – Add this entitlement and select the checkbox for “Remote notifications

That’s it really. From here you can start to work with SwiftUI views by adding the context into the environment for the initial view.

let contentView = ContentView().environment(\.managedObjectContext, context)

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Tumblr (Opens in new window) Tumblr
  • More
  • Click to print (Opens in new window) Print
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to share on Pinterest (Opens in new window) Pinterest
  • Click to share on Telegram (Opens in new window) Telegram
  • Click to share on WhatsApp (Opens in new window) WhatsApp

Like this:

Like Loading...
Post Tags: #CloudKit#CoreData
Next: SwiftUI – A note about onAppear()
Previous: Event Date List Row

Get my articles in your email

Subscribe

A-Frame AI AppUpdate AR BabylonJS Books Career ChatGPT CloudKit CoreData FileMaker Food Gaming Kadence MixedReality parody PlayCanvas Podcast SpatialComputing SwiftUI Thoughts visionOS VisionPro VR VueJS WebXR WordPress

Work with Me

Ready to streamline your workflows and enhance your digital presence?

Do you want to take your first step into Spatial Computing?

Discover how Radical Application Development can help transform your business.

Get in touch or learn more at radicalappdev.com

Mastodon Mastodon
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Privacy Policy

Follow my work

Github Linkedin YouTube

© 2025 Joseph Simpson | Radical Application Development

  • Canvatorium
  • Technical
  • Professional
  • Personal
 

Loading Comments...
 

    Search
    %d