     }
     
     private lazy var workingFilesDirectory: URL = {
-        let urls = FileManager.default.urls(for: self.directory, in: .userDomainMask)
-        let last = urls.last!
+        let baseDirecrtory: URL
+        if let group = groupIdentifier {
+            baseDirecrtory = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: group)!
+        } else {
+            let urls = FileManager.default.urls(for: self.directory, in: .userDomainMask)
+            baseDirecrtory = urls.last!
+        }
         let dbIdentifier = self.identifier + ".db"
-        let dbFolder = last.appendingPathComponent(dbIdentifier)
+        let dbFolder = baseDirecrtory.appendingPathComponent(dbIdentifier)
         do {
             try FileManager.default.createDirectory(at: dbFolder, withIntermediateDirectories: true, attributes: nil)
         } catch let error as NSError {

        }
    }
    
    public init(modelName: String, storeType: String = NSSQLiteStoreType, identifier: String = Bundle.main.bundleIdentifier!, bundle: Bundle = Bundle.main, in directory: FileManager.SearchPathDirectory = .documentDirectory, wipeOnConflict: Bool = false, sharedBackgroundContext: Bool = false) {
        stack = LegacyDataStack(modelName: modelName, type: storeType, identifier: identifier, bundle: bundle, in: directory, wipeOnConflict: wipeOnConflict, sharedBackgroundContext: sharedBackgroundContext)

        /*if #available(iOS 10, tvOS 10, *) {
            stack = CoreDataStack(modelName: modelName, type: storeType, identifier: identifier, in: directory, wipeOnConflict: wipeOnConflict)

    fileprivate let identifier: String
    fileprivate let bundle: Bundle
    private let directory: FileManager.SearchPathDirectory
    private let groupIdentifier: String?
    fileprivate let mergePolicy: NSMergePolicyType
    fileprivate let wipeOnConflict: Bool
    fileprivate let sharedBackgroundContext: Bool
