Sharing data with SwiftData

Hi, I have an app that uses Core Data + CloudKit, and which allows sharing of entities with other iCloud users. It works in a manner similar to the sample application provided on the Apple developer site.

Is this use case supported with SwiftData? The ability to share data with other iCloud users is fundamental to my app, so I cannot migrate to SwiftData unless this functionality is provided.

Post not yet marked as solved Up vote post of circus83 Down vote post of circus83
1.8k views

Replies

Same here. How to share data with SwiftData?

Initialize your ModelConfiguration with your cloudKitContainerIdentifier.

init(
    _ name: String? = nil,
    schema: Schema? = nil,
    url: URL,
    readOnly: Bool = false,
    cloudKitContainerIdentifier: String? = nil
)

See here for details. [https://developer.apple.com/documentation/swiftdata/modelconfiguration/init(_:schema:url:readonly:cloudkitcontaineridentifier:)?changes=_2_10)

  • The initializer above has changed with Beta 5. Go here for the new initializers.

Add a Comment