diff --git a/Sources/Setup/DataStack.swift b/Sources/Setup/DataStack.swift index d41791c..0a900a5 100644 --- a/Sources/Setup/DataStack.swift +++ b/Sources/Setup/DataStack.swift @@ -414,7 +414,16 @@ public final class DataStack { deinit { let coordinator = self.coordinator - coordinator.persistentStores.forEach { _ = try? coordinator.removePersistentStore($0) } + coordinator.performAsynchronously { + + withExtendedLifetime(coordinator) { coordinator in + + coordinator.persistentStores.forEach { + + _ = try? coordinator.removePersistentStore($0) + } + } + } }