Skip to content

Commit

Permalink
Add ability to store sync data in app group
Browse files Browse the repository at this point in the history
  • Loading branch information
Jann Schafranek committed Sep 18, 2024
1 parent 8c8b44a commit fb81603
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Sources/SwiftDataSync/Synchronizer/SDSSynchronizer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import Network
private let notificationCenter = NotificationCenter.default

public class SDSSynchronizer {

public static let shared = SDSSynchronizer()
public static var appGroupToStoreSyncData: String?

enum Constants {
static let zoneName = "CoreData"
Expand Down Expand Up @@ -71,6 +71,14 @@ public class SDSSynchronizer {
managedObjectModel: model
)

if
let appGroup = Self.appGroupToStoreSyncData,
let containerUrl = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: appGroup)
{
container.persistentStoreDescriptions = [
.init(url: containerUrl.appendingPathComponent("CloudKitSync.sqlite"))
]
}
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
if let error {
fatalError("Unresolved error \(error)")
Expand Down

0 comments on commit fb81603

Please sign in to comment.