From 83c724f58447849bd7507d45dc7fae36e7ca8dce Mon Sep 17 00:00:00 2001 From: John Rommel Estropia Date: Sat, 8 Aug 2015 22:12:08 +0900 Subject: [PATCH] updated default logger to still run assertions even on optimized (-O) builds --- CoreStore.podspec | 2 +- CoreStore/Info.plist | 2 +- CoreStore/Logging/DefaultLogger.swift | 7 +++++- .../DetachedDataTransaction.swift | 24 +++++++++---------- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/CoreStore.podspec b/CoreStore.podspec index 3bda7e8..e8e2abf 100644 --- a/CoreStore.podspec +++ b/CoreStore.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "CoreStore" - s.version = "1.0.2" + s.version = "1.1.2" s.license = "MIT" s.summary = "Simple, elegant, and smart Core Data programming with Swift" s.homepage = "https://github.com/JohnEstropia/CoreStore" diff --git a/CoreStore/Info.plist b/CoreStore/Info.plist index 9645e5d..3034b22 100644 --- a/CoreStore/Info.plist +++ b/CoreStore/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0.2 + 1.1.2 CFBundleSignature ???? CFBundleVersion diff --git a/CoreStore/Logging/DefaultLogger.swift b/CoreStore/Logging/DefaultLogger.swift index 1ebf61a..7df9c98 100644 --- a/CoreStore/Logging/DefaultLogger.swift +++ b/CoreStore/Logging/DefaultLogger.swift @@ -76,7 +76,12 @@ public final class DefaultLogger: CoreStoreLogger { public func assert(@autoclosure condition: () -> Bool, message: String, fileName: StaticString, lineNumber: Int, functionName: StaticString) { #if DEBUG - Swift.assert(condition, "❗ [CoreStore: Assertion Failure] \(message)", file: fileName, line: numericCast(lineNumber)) + if condition() { + + return + } + Swift.print("❗ [CoreStore: Assertion Failure] \((fileName.stringValue as NSString).lastPathComponent):\(lineNumber) \(functionName)\n ↪︎ \(message)\n") + Swift.fatalError() #endif } } diff --git a/CoreStore/Saving and Processing/DetachedDataTransaction.swift b/CoreStore/Saving and Processing/DetachedDataTransaction.swift index d636b7a..1cf7dd0 100644 --- a/CoreStore/Saving and Processing/DetachedDataTransaction.swift +++ b/CoreStore/Saving and Processing/DetachedDataTransaction.swift @@ -36,18 +36,6 @@ public final class DetachedDataTransaction: BaseDataTransaction { // MARK: Public - /** - Returns the `NSManagedObjectContext` for this detached transaction. Use only for cases where external frameworks need an `NSManagedObjectContext` instance to work with. - - Note that it is the developer's responsibility to ensure the following: - - that the `DetachedDataTransaction` that owns this context should be strongly referenced and prevented from being deallocated during the context's lifetime - - that all saves will be done either through the `DetachedDataTransaction`'s `commit(...)` method, or by calling `save()` manually on the context, its parent, and all other ancestor contexts if there are any. - */ - public var internalContext: NSManagedObjectContext { - - return self.context - } - /** Saves the transaction changes asynchronously. For a `DetachedDataTransaction`, multiple commits are allowed, although it is the developer's responsibility to ensure a reasonable leeway to prevent blocking the main thread. @@ -75,6 +63,18 @@ public final class DetachedDataTransaction: BaseDataTransaction { ) } + /** + Returns the `NSManagedObjectContext` for this detached transaction. Use only for cases where external frameworks need an `NSManagedObjectContext` instance to work with. + + Note that it is the developer's responsibility to ensure the following: + - that the `DetachedDataTransaction` that owns this context should be strongly referenced and prevented from being deallocated during the context's lifetime + - that all saves will be done either through the `DetachedDataTransaction`'s `commit(...)` method, or by calling `save()` manually on the context, its parent, and all other ancestor contexts if there are any. + */ + public var internalContext: NSManagedObjectContext { + + return self.context + } + // MARK: Internal