What are best practices for implementing data persistence on a watch only app?

I’m currently working on a watch only app and I’m trying to understand how best to persist my model data for the user’s data. I plan to release for watchOS 7. I plan to use SwiftUI. I’m still trying to decide if I continue using a WatchKit extension project structure (created from Xcode 11) or start again with a 100% SwiftUI watch only project using Xcode 12. Does that affect selection of a data persistance approach?

I’ve used CloudKit for data persistance in my iOS app. I guess I could do this again For my watchOS app, or maybe in conjunction with Core Data, but how do I assess the various options? What are the best practices in choosing an approach to persist model data for a watch app? My model data won’t be too complex. Just an array of items, each item consisting of a string and image.

Any recommendations are welcome.

Accepted Reply

This sounds like a good use case for Core Data, you can use it with any app architecture. CloudKit is not a solution for local persistence, it is basically a transport technology that you can use to store data in iCloud, synchronize data between a user's devices, or share content with other users.
If you want your data to stay on the watch, NSPersistentContainer is your best option. If you want to sync data with your iOS app, use NSPersistentCloudKitContainer. The latter makes use of CloudKit to automatically mirror all local changes to iCloud and other devices.

Replies

This sounds like a good use case for Core Data, you can use it with any app architecture. CloudKit is not a solution for local persistence, it is basically a transport technology that you can use to store data in iCloud, synchronize data between a user's devices, or share content with other users.
If you want your data to stay on the watch, NSPersistentContainer is your best option. If you want to sync data with your iOS app, use NSPersistentCloudKitContainer. The latter makes use of CloudKit to automatically mirror all local changes to iCloud and other devices.
Ok. Since this is a watch only app and I don’t need to sync data with other devices, it sounds like using CloudKit is not necessary and I can use Core Data for local on-watch data persistence.

What is the latest and greatest information I can reference for using Core Data for my situation (Xcode 12 beta, watch only watchOS 7 app, SwiftUI)? Is there a WWDC20 video session that covers my situation? Example code?
This session from last year's WWDC might be good place to start: https://developer.apple.com/videos/play/wwdc2019/230/