I’m writing a simple trip-planning app and I want to allow multiple users to collaborate on a trip. I have a SwiftData Trip
model object. From the trip’s main UI, I’m trying to use ShareLink
to start collaboration, but I can’t even figure out how to just share a Trip
object (e.g. ShareLink(item: self.trip)
). The item passed to ShareLink
must conform to Transferable
, and I can’t find any examples of how to do that to start CloudKit sharing of an object, let alone collaboration.
One example I did find for CloudKit collaboration is UIKit-centric, and has a lot of stuff about zones and caching that obscure the basic collaboration setup. And it knows nothing about SwiftData.
This guide also shows a standard collaboration toolbar icon that you’re supposed to display after collaboration has begun, and it implies there’s a system-provided sheet to display when tapped, but it’s not clear to me how to do that in SwiftUI.
Does anyone know how to collaborate with a shared SwiftData object?