Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .swiftformat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--extensionacl on-declarations
--redundanttype explicit
--swiftversion 5.8
--swiftversion 5.10
--maxwidth 120
--header "{file}\nCoreDataRepository\n\nThis source code is licensed under the MIT License (MIT) found in the\nLICENSE file in the root directory of this source tree."
--allman false
Expand Down
36 changes: 36 additions & 0 deletions CoreDataRepository.xctestplan
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"configurations" : [
{
"id" : "3473C2E6-8765-4CE5-8DCC-FAF7D66E9FD2",
"name" : "Test Scheme Action",
"options" : {

}
}
],
"defaultOptions" : {
"commandLineArgumentEntries" : [
{
"argument" : "-com.apple.CoreData.ConcurrencyDebug 1"
},
{
"argument" : "-com.apple.CoreData.SQLDebug 4",
"enabled" : false
},
{
"argument" : "-com.apple.CoreData.SQLDebug 4",
"enabled" : false
}
]
},
"testTargets" : [
{
"target" : {
"containerPath" : "container:",
"identifier" : "CoreDataRepositoryTests",
"name" : "CoreDataRepositoryTests"
}
}
],
"version" : 1
}
42 changes: 20 additions & 22 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,25 @@ let package = Package(
)

extension [SupportedPlatform] {
static let shared: Self = {
if ProcessInfo.benchmarkingEnabled {
[
.iOS(.v15),
.macOS(.v12),
.tvOS(.v15),
.watchOS(.v8),
.macCatalyst(.v15),
.visionOS(.v1),
]
} else {
[
.iOS(.v15),
.macOS(.v13),
.tvOS(.v15),
.watchOS(.v8),
.macCatalyst(.v15),
.visionOS(.v1),
]
}
}()
static let shared: Self = if ProcessInfo.benchmarkingEnabled {
[
.iOS(.v15),
.macOS(.v12),
.tvOS(.v15),
.watchOS(.v8),
.macCatalyst(.v15),
.visionOS(.v1),
]
} else {
[
.iOS(.v15),
.macOS(.v13),
.tvOS(.v15),
.watchOS(.v8),
.macCatalyst(.v15),
.visionOS(.v1),
]
}
}

extension [SwiftSetting] {
Expand All @@ -76,7 +74,7 @@ extension [SwiftSetting] {
.enableUpcomingFeature("DisableOutwardActorInference"),
.enableUpcomingFeature("ForwardTrailingClosures"),
.enableUpcomingFeature("ImportObjcForwardDeclarations"),
.enableExperimentalFeature("StrictConcurrency"),
.enableUpcomingFeature("StrictConcurrency"),
]
}

Expand Down
66 changes: 33 additions & 33 deletions Sources/CoreDataRepository/CoreDataError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,65 +59,65 @@ public enum CoreDataError: Error, Hashable, Sendable {
public var localizedDescription: String {
switch self {
case .failedToGetObjectIdFromUrl:
return NSLocalizedString(
NSLocalizedString(
"No NSManagedObjectID found that correlates to the provided URL.",
bundle: .module,
comment: "Error for when an ObjectID can't be found for the provided URL."
)
case .propertyDoesNotMatchEntity:
return NSLocalizedString(
NSLocalizedString(
"There is a mismatch between a provided NSPropertyDescrption's entity and a NSEntityDescription. "
+ "When a property description is provided, it must match any related entity descriptions.",
bundle: .module,
comment: "Error for when the developer does not provide a valid pair of NSAttributeDescription "
+ "and NSPropertyDescription (or any of their child types)."
)
case .fetchedObjectFailedToCastToExpectedType:
return NSLocalizedString(
NSLocalizedString(
"The object corresponding to the provided NSManagedObjectID is an incorrect Entity or "
+ "NSManagedObject subtype. It failed to cast to the requested type.",
bundle: .module,
comment: "Error for when an object is found for a given ObjectID but it is not the expected type."
)
case .fetchedObjectIsFlaggedAsDeleted:
return NSLocalizedString(
NSLocalizedString(
"The object corresponding to the provided NSManagedObjectID is deleted and cannot be fetched.",
bundle: .module,
comment: "Error for when an object is fetched but is flagged as deleted and is no longer usable."
)
case let .cocoa(error):
return error.localizedDescription
error.localizedDescription
case let .unknown(error):
return error.localizedDescription
error.localizedDescription
case .noEntityNameFound:
return NSLocalizedString(
NSLocalizedString(
"The managed object entity description does not have a name.",
bundle: .module,
comment: "Error for when the NSEntityDescription does not have a name."
)
case .atLeastOneAttributeDescRequired:
return NSLocalizedString(
NSLocalizedString(
"The managed object entity has no attribute description. An attribute description is required for "
+ "aggregate operations.",
bundle: .module,
comment: "Error for when the NSEntityDescription has no NSAttributeDescription but one is required."
)
case .noUrlOnItemToMapToObjectId:
return NSLocalizedString(
NSLocalizedString(
"No object ID URL found on the model for an operation against an existing managed object.",
bundle: .module,
comment: "Error for performing an operation against an existing NSManagedObject but the "
+ "ManagedIdUrlReferencable instance has no managedIdUrl for looking up the NSManagedOjbectID."
)
case .noObjectIdOnItem:
return NSLocalizedString(
NSLocalizedString(
"No object ID found on the model for an operation against an existing managed object.",
bundle: .module,
comment: "Error for performing an operation against an existing NSManagedObject but the "
+ "ManagedIdReferencable instance has no managedId."
)
case .noMatchFoundWhenReadingItem:
return NSLocalizedString(
NSLocalizedString(
"No match found when attempting to read an instance from CoreData.",
bundle: .module,
comment: "Error for reading an instance from CoreData but no instance was found."
Expand All @@ -133,27 +133,27 @@ extension CoreDataError: CustomNSError {
public var errorCode: Int {
switch self {
case .failedToGetObjectIdFromUrl:
return 1
1
case .propertyDoesNotMatchEntity:
return 2
2
case .fetchedObjectFailedToCastToExpectedType:
return 3
3
case .fetchedObjectIsFlaggedAsDeleted:
return 4
4
case .cocoa:
return 5
5
case .unknown:
return 6
6
case .noEntityNameFound:
return 7
7
case .atLeastOneAttributeDescRequired:
return 8
8
case .noUrlOnItemToMapToObjectId:
return 9
9
case .noObjectIdOnItem:
return 10
10
case .noMatchFoundWhenReadingItem:
return 11
11
}
}

Expand All @@ -163,27 +163,27 @@ extension CoreDataError: CustomNSError {
public var errorUserInfo: [String: Any] {
switch self {
case let .failedToGetObjectIdFromUrl(url):
return [Self.urlUserInfoKey: url]
[Self.urlUserInfoKey: url]
case .propertyDoesNotMatchEntity:
return [:]
[:]
case .fetchedObjectFailedToCastToExpectedType:
return [:]
[:]
case .fetchedObjectIsFlaggedAsDeleted:
return [:]
[:]
case let .cocoa(error):
return error.userInfo
error.userInfo
case let .unknown(error):
return error.userInfo
error.userInfo
case .noEntityNameFound:
return [:]
[:]
case .atLeastOneAttributeDescRequired:
return [:]
[:]
case .noUrlOnItemToMapToObjectId:
return [:]
[:]
case .noObjectIdOnItem:
return [:]
[:]
case .noMatchFoundWhenReadingItem:
return [:]
[:]
}
}
}
Loading