From 5ca0f657cbaa131e5a63e971b6b6e4a9b3abd8bb Mon Sep 17 00:00:00 2001 From: John Estropia Date: Wed, 23 Mar 2016 12:07:31 +0900 Subject: [PATCH 1/3] XCode 7.3 fixes --- .../Importing Data/ImportableObject.swift | 2 +- .../ImportableUniqueObject.swift | 4 ++-- .../Internal/NSManagedObjectModel+Setup.swift | 22 ++++++++++--------- CoreStore/Logging/CoreStore+Logging.swift | 6 ++--- CoreStore/Migrating/MigrationChain.swift | 16 ++++++++------ CoreStore/Observing/ListObserver.swift | 2 +- CoreStore/Observing/ObjectObserver.swift | 2 +- 7 files changed, 29 insertions(+), 25 deletions(-) diff --git a/CoreStore/Importing Data/ImportableObject.swift b/CoreStore/Importing Data/ImportableObject.swift index a24b767..7570f32 100644 --- a/CoreStore/Importing Data/ImportableObject.swift +++ b/CoreStore/Importing Data/ImportableObject.swift @@ -53,7 +53,7 @@ public protocol ImportableObject: class { /** The data type for the import source. This is most commonly an `NSDictionary` or another external source such as an `NSUserDefaults`. */ - typealias ImportSource + associatedtype ImportSource /** Return `true` if an object should be created from `source`. Return `false` to ignore and skip `source`. The default implementation returns `true`. diff --git a/CoreStore/Importing Data/ImportableUniqueObject.swift b/CoreStore/Importing Data/ImportableUniqueObject.swift index 5c23467..d5f7dc4 100644 --- a/CoreStore/Importing Data/ImportableUniqueObject.swift +++ b/CoreStore/Importing Data/ImportableUniqueObject.swift @@ -54,12 +54,12 @@ public protocol ImportableUniqueObject: ImportableObject { /** The data type for the import source. This is most commonly an `NSDictionary` or another external source such as an `NSUserDefaults`. */ - typealias ImportSource + associatedtype ImportSource /** The data type for the entity's unique ID attribute */ - typealias UniqueIDType: NSObject + associatedtype UniqueIDType: NSObject /** The keyPath to the entity's unique ID attribute diff --git a/CoreStore/Internal/NSManagedObjectModel+Setup.swift b/CoreStore/Internal/NSManagedObjectModel+Setup.swift index 9d0bac0..09a089f 100644 --- a/CoreStore/Internal/NSManagedObjectModel+Setup.swift +++ b/CoreStore/Internal/NSManagedObjectModel+Setup.swift @@ -154,12 +154,13 @@ internal extension NSManagedObjectModel { } @nonobjc internal func entityTypesMapping() -> [String: NSManagedObject.Type] { - - return self.entityNameMapping.reduce([:]) { (var mapping, pair) in + + var mapping = [String: NSManagedObject.Type]() + self.entityNameMapping.forEach { (className, entityName) in - mapping[pair.1] = (NSClassFromString(pair.0)! as! NSManagedObject.Type) - return mapping + mapping[entityName] = (NSClassFromString(className)! as! NSManagedObject.Type) } + return mapping } @nonobjc internal func mergedModels() -> [NSManagedObjectModel] { @@ -249,15 +250,16 @@ internal extension NSManagedObjectModel { return mapping as! [String: String] } - let mapping = self.entities.reduce([String: String]()) { - (var mapping, entityDescription) -> [String: String] in + var mapping = [String: String]() + self.entities.forEach { - if let entityName = entityDescription.name { + guard let entityName = $0.name else { - let className = entityDescription.managedObjectClassName - mapping[className] = entityName + return } - return mapping + + let className = $0.managedObjectClassName + mapping[className] = entityName } setAssociatedCopiedObject( mapping as NSDictionary, diff --git a/CoreStore/Logging/CoreStore+Logging.swift b/CoreStore/Logging/CoreStore+Logging.swift index 5bfe79c..76a3bc7 100644 --- a/CoreStore/Logging/CoreStore+Logging.swift +++ b/CoreStore/Logging/CoreStore+Logging.swift @@ -38,7 +38,7 @@ public extension CoreStore { // MARK: Internal - internal static func log(level: LogLevel, message: String, fileName: StaticString = __FILE__, lineNumber: Int = __LINE__, functionName: StaticString = __FUNCTION__) { + internal static func log(level: LogLevel, message: String, fileName: StaticString = #file, lineNumber: Int = #line, functionName: StaticString = #function) { self.logger.log( level: level, @@ -49,7 +49,7 @@ public extension CoreStore { ) } - internal static func handleError(error: NSError, _ message: String, fileName: StaticString = __FILE__, lineNumber: Int = __LINE__, functionName: StaticString = __FUNCTION__) { + internal static func handleError(error: NSError, _ message: String, fileName: StaticString = #file, lineNumber: Int = #line, functionName: StaticString = #function) { self.logger.handleError( error: error, @@ -60,7 +60,7 @@ public extension CoreStore { ) } - internal static func assert(@autoclosure condition: () -> Bool, _ message: String, fileName: StaticString = __FILE__, lineNumber: Int = __LINE__, functionName: StaticString = __FUNCTION__) { + internal static func assert(@autoclosure condition: () -> Bool, _ message: String, fileName: StaticString = #file, lineNumber: Int = #line, functionName: StaticString = #function) { self.logger.assert( condition, diff --git a/CoreStore/Migrating/MigrationChain.swift b/CoreStore/Migrating/MigrationChain.swift index b57cfd6..d544ffb 100644 --- a/CoreStore/Migrating/MigrationChain.swift +++ b/CoreStore/Migrating/MigrationChain.swift @@ -111,22 +111,24 @@ public struct MigrationChain: NilLiteralConvertible, StringLiteralConvertible, D public init(dictionaryLiteral elements: (String, String)...) { var valid = true - let versionTree = elements.reduce([String: String]()) { (var versionTree, tuple: (String, String)) -> [String: String] in + var versionTree = [String: String]() + elements.forEach { (sourceVersion, destinationVersion) in - if let _ = versionTree.updateValue(tuple.1, forKey: tuple.0) { + guard let _ = versionTree.updateValue(destinationVersion, forKey: sourceVersion) else { - CoreStore.assert(false, "\(typeName(MigrationChain))'s migration chain could not be created due to ambiguous version paths.") - - valid = false + return } - return versionTree + + CoreStore.assert(false, "\(typeName(MigrationChain))'s migration chain could not be created due to ambiguous version paths.") + + valid = false } let leafVersions = Set( elements.filter { (tuple: (String, String)) -> Bool in return versionTree[tuple.1] == nil - }.map { $1 } + }.map { $1 } ) let isVersionAmbiguous = { (start: String) -> Bool in diff --git a/CoreStore/Observing/ListObserver.swift b/CoreStore/Observing/ListObserver.swift index 67ced6a..61c11c8 100644 --- a/CoreStore/Observing/ListObserver.swift +++ b/CoreStore/Observing/ListObserver.swift @@ -45,7 +45,7 @@ public protocol ListObserver: class { /** The `NSManagedObject` type for the observed list */ - typealias ListEntityType: NSManagedObject + associatedtype ListEntityType: NSManagedObject /** Handles processing just before a change to the observed list occurs diff --git a/CoreStore/Observing/ObjectObserver.swift b/CoreStore/Observing/ObjectObserver.swift index 0188b0a..ca662bd 100644 --- a/CoreStore/Observing/ObjectObserver.swift +++ b/CoreStore/Observing/ObjectObserver.swift @@ -42,7 +42,7 @@ public protocol ObjectObserver: class { /** The `NSManagedObject` type for the observed object */ - typealias ObjectEntityType: NSManagedObject + associatedtype ObjectEntityType: NSManagedObject /** Handles processing just before a change to the observed `object` occurs From dc6d22b6ff45cb5325f9cd13d3914c5960dc36af Mon Sep 17 00:00:00 2001 From: John Estropia Date: Wed, 23 Mar 2016 12:14:34 +0900 Subject: [PATCH 2/3] updated travis XCode version --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ad15d8a..90724b2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: objective-c -osx_image: xcode7.2 +osx_image: xcode7.3 sudo: false git: submodules: false From 928585029d9264e15f41f66aa65055a08051aaab Mon Sep 17 00:00:00 2001 From: John Estropia Date: Wed, 23 Mar 2016 12:39:11 +0900 Subject: [PATCH 3/3] XCode 7.3 full support --- .travis.yml | 20 ++++++++++---------- Carthage/Checkouts/GCDKit | 2 +- CoreStore.podspec | 4 ++-- CoreStore/CartFile | 2 +- CoreStore/Info.plist | 2 +- README.md | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 90724b2..5baf74c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,15 +10,15 @@ env: - LC_CTYPE=en_US.UTF-8 - LANG=en_US.UTF-8 matrix: - - DESTINATION="OS=9.2,name=iPhone 6s" SCHEME="CoreStore iOS" SDK=iphonesimulator9.2 RUN_TESTS="YES" POD_LINT="NO" - - DESTINATION="OS=9.0,name=iPhone 6 Plus" SCHEME="CoreStore iOS" SDK=iphonesimulator9.2 RUN_TESTS="YES" POD_LINT="NO" - - DESTINATION="OS=8.4,name=iPhone 6" SCHEME="CoreStore iOS" SDK=iphonesimulator9.2 RUN_TESTS="YES" POD_LINT="NO" - - DESTINATION="OS=8.3,name=iPhone 5S" SCHEME="CoreStore iOS" SDK=iphonesimulator9.2 RUN_TESTS="YES" POD_LINT="NO" - - DESTINATION="OS=8.2,name=iPhone 5" SCHEME="CoreStore iOS" SDK=iphonesimulator9.2 RUN_TESTS="YES" POD_LINT="NO" - - DESTINATION="OS=8.1,name=iPhone 4S" SCHEME="CoreStore iOS" SDK=iphonesimulator9.2 RUN_TESTS="YES" POD_LINT="YES" + - DESTINATION="OS=9.3,name=iPhone 6s" SCHEME="CoreStore iOS" SDK=iphonesimulator9.3 RUN_TESTS="YES" POD_LINT="NO" + - DESTINATION="OS=9.0,name=iPhone 6 Plus" SCHEME="CoreStore iOS" SDK=iphonesimulator9.3 RUN_TESTS="YES" POD_LINT="NO" + - DESTINATION="OS=8.4,name=iPhone 6" SCHEME="CoreStore iOS" SDK=iphonesimulator9.3 RUN_TESTS="YES" POD_LINT="NO" + - DESTINATION="OS=8.3,name=iPhone 5S" SCHEME="CoreStore iOS" SDK=iphonesimulator9.3 RUN_TESTS="YES" POD_LINT="NO" + - DESTINATION="OS=8.2,name=iPhone 5" SCHEME="CoreStore iOS" SDK=iphonesimulator9.3 RUN_TESTS="YES" POD_LINT="NO" + - DESTINATION="OS=8.1,name=iPhone 4S" SCHEME="CoreStore iOS" SDK=iphonesimulator9.3 RUN_TESTS="YES" POD_LINT="YES" - DESTINATION="arch=x86_64" SCHEME="CoreStore OSX" SDK=macosx10.11 RUN_TESTS="YES" POD_LINT="NO" - - DESTINATION="OS=2.1,name=Apple Watch - 42mm" SCHEME="CoreStore watchOS" SDK=watchsimulator2.1 RUN_TESTS="NO" POD_LINT="NO" - - DESTINATION="OS=9.1,name=Apple TV 1080p" SCHEME="CoreStore tvOS" SDK=appletvsimulator9.1 RUN_TESTS="YES" POD_LINT="NO" + - DESTINATION="OS=2.2,name=Apple Watch - 42mm" SCHEME="CoreStore watchOS" SDK=watchsimulator2.2 RUN_TESTS="NO" POD_LINT="NO" + - DESTINATION="OS=9.2,name=Apple TV 1080p" SCHEME="CoreStore tvOS" SDK=appletvsimulator9.2 RUN_TESTS="YES" POD_LINT="NO" before_install: - gem install cocoapods --no-rdoc --no-ri --no-document --quiet - gem install xcpretty --no-rdoc --no-ri --no-document --quiet @@ -35,8 +35,8 @@ script: xcodebuild -workspace CoreStore.xcworkspace -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Debug ONLY_ACTIVE_ARCH=NO clean test | xcpretty -c; xcodebuild -workspace CoreStore.xcworkspace -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Release ONLY_ACTIVE_ARCH=NO clean test | xcpretty -c; fi - - xcodebuild -workspace "CoreStore.xcworkspace" -scheme "CoreStore iOS" -sdk "iphonesimulator9.2" -destination "OS=9.2,name=iPhone 6s" -configuration Debug ONLY_ACTIVE_ARCH=NO clean test | xcpretty -c; - - xcodebuild -workspace "CoreStore.xcworkspace" -scheme "CoreStore iOS" -sdk "iphonesimulator9.2" -destination "OS=9.2,name=iPhone 6s" -configuration Release ONLY_ACTIVE_ARCH=NO clean test | xcpretty -c; + - xcodebuild -workspace "CoreStore.xcworkspace" -scheme "CoreStore iOS" -sdk "iphonesimulator9.3" -destination "OS=9.3,name=iPhone 6s" -configuration Debug ONLY_ACTIVE_ARCH=NO clean test | xcpretty -c; + - xcodebuild -workspace "CoreStore.xcworkspace" -scheme "CoreStore iOS" -sdk "iphonesimulator9.3" -destination "OS=9.3,name=iPhone 6s" -configuration Release ONLY_ACTIVE_ARCH=NO clean test | xcpretty -c; - if [ $POD_LINT == "YES" ]; then pod lib lint --quick; fi diff --git a/Carthage/Checkouts/GCDKit b/Carthage/Checkouts/GCDKit index 7f6b560..5d8c347 160000 --- a/Carthage/Checkouts/GCDKit +++ b/Carthage/Checkouts/GCDKit @@ -1 +1 @@ -Subproject commit 7f6b560ffd4ba0f7b1c6f1ec7e17d32928a9858b +Subproject commit 5d8c34772c32573cb8892e83596071c80fcfe0ad diff --git a/CoreStore.podspec b/CoreStore.podspec index 2b4365b..8ffcebb 100644 --- a/CoreStore.podspec +++ b/CoreStore.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "CoreStore" - s.version = "1.5.3" + s.version = "1.5.4" s.license = "MIT" s.summary = "Unleashing the real power of Core Data with the elegance and safety of Swift" s.homepage = "https://github.com/JohnEstropia/CoreStore" @@ -18,5 +18,5 @@ Pod::Spec.new do |s| s.requires_arc = true s.pod_target_xcconfig = { 'OTHER_SWIFT_FLAGS' => '-D USE_FRAMEWORKS' } - s.dependency "GCDKit", "1.1.7" + s.dependency "GCDKit", "1.2.1" end \ No newline at end of file diff --git a/CoreStore/CartFile b/CoreStore/CartFile index d8f515a..02fe6a3 100644 --- a/CoreStore/CartFile +++ b/CoreStore/CartFile @@ -1 +1 @@ -github "JohnEstropia/GCDKit" == 1.1.7 +github "JohnEstropia/GCDKit" == 1.2.1 diff --git a/CoreStore/Info.plist b/CoreStore/Info.plist index 77238c6..a5a90db 100644 --- a/CoreStore/Info.plist +++ b/CoreStore/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.5.3 + 1.5.4 CFBundleSignature ???? CFBundleVersion diff --git a/README.md b/README.md index c8635b9..ee60c5d 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) Unleashing the real power of Core Data with the elegance and safety of Swift -* Swift 2.1 (Xcode 7.1), iOS 8+/OSX 10.10+ (or try out the [iOS 7 branch](https://github.com/JohnEstropia/CoreStore/tree/ios7_support_alpha)) +* Swift 2.2 (Xcode 7.3), iOS 8+/OSX 10.10+ (or try out the [iOS 7 branch](https://github.com/JohnEstropia/CoreStore/tree/ios7_support_alpha)) [Click here for a wiki version of this README](https://github.com/JohnEstropia/CoreStore/wiki)