diff --git a/Package.swift b/Package.swift index fd66ca9d..c9460916 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.0 +// swift-tools-version:5.3 // // Package.swift // CoreStore @@ -40,7 +40,7 @@ let package = Package( name: "CoreStore", dependencies: [], path: "Sources", - exclude: ["CoreStoreBridge.h", "CoreStoreBridge.m"] + exclude: ["CoreStoreBridge.h", "CoreStoreBridge.m", "ObjectPublisher+Reactive.swift", "Info.plist"] ), .testTarget( name: "CoreStoreTests", diff --git a/Sources/From.swift b/Sources/From.swift index c12bbefb..84f7e61c 100644 --- a/Sources/From.swift +++ b/Sources/From.swift @@ -149,7 +149,8 @@ public struct From { ) throw CoreStoreError.unknown } - fetchRequest.entity = parentStack.entityDescription(for: Internals.EntityIdentifier(self.entityClass))! + guard let entity = parentStack.entityDescription(for: Internals.EntityIdentifier(self.entityClass)) else { return } + fetchRequest.entity = entity guard applyAffectedStores else { return diff --git a/Sources/SQLiteStore.swift b/Sources/SQLiteStore.swift index f8d2abcb..879e4092 100644 --- a/Sources/SQLiteStore.swift +++ b/Sources/SQLiteStore.swift @@ -74,12 +74,13 @@ public final class SQLiteStore: LocalStorage { - Warning: The default SQLite file location for the `LegacySQLiteStore` and `SQLiteStore` are different. If the app was depending on CoreStore's default directories prior to 2.0.0, make sure to use the `SQLiteStore.legacy(...)` factory methods to create the `SQLiteStore` instead of using initializers directly. */ - public init() { + public init(secure: Bool = false) { self.fileURL = SQLiteStore.defaultFileURL self.configuration = nil self.migrationMappingProviders = [] self.localStorageOptions = nil + self.secure = secure } /** @@ -133,7 +134,8 @@ public final class SQLiteStore: LocalStorage { // MARK: StorageInterface - + private var secure: Bool = false + /** The string identifier for the `NSPersistentStore`'s `type` property. For `SQLiteStore`s, this is always set to `NSSQLiteStoreType`. */ @@ -217,6 +219,9 @@ public final class SQLiteStore: LocalStorage { var storeOptions = self.storeOptions ?? [:] storeOptions[NSSQLitePragmasOption] = ["journal_mode": "DELETE"] + if secure { + storeOptions[NSPersistentStoreFileProtectionKey] = FileProtectionType.complete + } try coordinator.addPersistentStore( ofType: Self.storeType, configurationName: self.configuration,