From 23c35bbe022c776a60484a3ef4ad96fd056b95de Mon Sep 17 00:00:00 2001 From: Jared Sorge Date: Sat, 4 Aug 2018 08:53:45 -0700 Subject: [PATCH 1/4] silencing warnings on Xcode 10 --- Package.resolved | 34 +++++++++++++++++++++++++++++++++ Sources/CKPredicateReader.swift | 2 +- Sources/CKPrettyError.swift | 3 ++- Sources/CKQueryOperation.swift | 2 +- Sources/CKReference.swift | 4 ++-- 5 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 Package.resolved diff --git a/Package.resolved b/Package.resolved new file mode 100644 index 0000000..632d0d8 --- /dev/null +++ b/Package.resolved @@ -0,0 +1,34 @@ +{ + "object": { + "pins": [ + { + "package": "CLibreSSL", + "repositoryURL": "https://github.com/vapor/clibressl.git", + "state": { + "branch": null, + "revision": "23ddb296981d17a8ee6c7418742a40cad5d2f9d0", + "version": "1.0.0" + } + }, + { + "package": "CryptoSwift", + "repositoryURL": "https://github.com/krzyzanowskim/CryptoSwift.git", + "state": { + "branch": null, + "revision": "3f6869c469abf3e2ebefe3b6baef4bfac3aac305", + "version": "0.11.0" + } + }, + { + "package": "Jay", + "repositoryURL": "https://github.com/DanToml/Jay.git", + "state": { + "branch": null, + "revision": "833125251b2d026bee6afa0aff2967a90eb63cd0", + "version": "1.0.1" + } + } + ] + }, + "version": 1 +} diff --git a/Sources/CKPredicateReader.swift b/Sources/CKPredicateReader.swift index d6ee2c9..41b96ed 100755 --- a/Sources/CKPredicateReader.swift +++ b/Sources/CKPredicateReader.swift @@ -30,7 +30,7 @@ struct CKPredicateReader { } func hasNext(_ input: Index) -> Bool { - return input + step <= buffer.characters.count + return input + step <= buffer.count } func takeCharacter(_ input: Index) -> (Character, Index)? { diff --git a/Sources/CKPrettyError.swift b/Sources/CKPrettyError.swift index f4934f7..c615582 100755 --- a/Sources/CKPrettyError.swift +++ b/Sources/CKPrettyError.swift @@ -115,6 +115,7 @@ class CKPrettyError: NSError { override public var description: String { // \(withUnsafePointer(to: self)) - return " Date: Sat, 4 Aug 2018 08:55:08 -0700 Subject: [PATCH 2/4] CI update --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 177b775..2361a3d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,12 +4,12 @@ os: language: generic sudo: required dist: trusty -osx_image: xcode9.2 +osx_image: xcode10 script: - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then DIR="$(pwd)"; cd ..; - export SWIFT_VERSION=4.0.3; + export SWIFT_VERSION=4.1; wget https://swift.org/builds/swift-${SWIFT_VERSION}-release/ubuntu1404/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-ubuntu14.04.tar.gz; tar xzf swift-${SWIFT_VERSION}-RELEASE-ubuntu14.04.tar.gz; export PATH="${PWD}/swift-${SWIFT_VERSION}-RELEASE-ubuntu14.04/usr/bin:${PATH}"; From 63df00c1d2f2186b0b8042a8fa92fd8a93a84d50 Mon Sep 17 00:00:00 2001 From: Jared Sorge Date: Sun, 5 Aug 2018 16:34:07 -0700 Subject: [PATCH 3/4] CI fix --- Sources/CKQueryOperation.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/CKQueryOperation.swift b/Sources/CKQueryOperation.swift index f1ce397..f026dea 100755 --- a/Sources/CKQueryOperation.swift +++ b/Sources/CKQueryOperation.swift @@ -45,7 +45,7 @@ public class CKQueryOperation: CKDatabaseOperation { public var recordFetchedBlock: ((CKRecord) -> Swift.Void)? - public var queryCompletionBlock: ((CKQueryCursor?, NSError?) -> Swift.Void)? + public var queryCompletionBlock: ((CKQueryCursor?, Error?) -> Swift.Void)? override func CKOperationShouldRun() throws { // "Warn: There's no point in running a query if there are no progress or completion blocks set. Bailing early." @@ -57,7 +57,7 @@ public class CKQueryOperation: CKDatabaseOperation { override func finishOnCallbackQueue(error: Error?) { // log "Operation %@ has completed. Query cursor is %@.%@%@" - self.queryCompletionBlock?(self.resultsCursor, error as NSError?) + self.queryCompletionBlock?(self.resultsCursor, error) super.finishOnCallbackQueue(error: error) } From 88a09f3b07d3e25425fbca568175390fa47668c7 Mon Sep 17 00:00:00 2001 From: Jared Sorge Date: Sun, 5 Aug 2018 13:56:37 -0700 Subject: [PATCH 4/4] Inject known record ID to record creation When fetching records from CloudKit, a new recordID properyt was being created in the processing, which meant that the record IDs would be different instances, and the dictionary lookup could fail. --- Sources/CKFetchRecordsOperation.swift | 2 +- Sources/CKRecord.swift | 12 ++++++++---- Sources/CKRecordID.swift | 4 ++++ Sources/OpenCloudKit.swift | 6 +++++- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Sources/CKFetchRecordsOperation.swift b/Sources/CKFetchRecordsOperation.swift index aa210d4..90b6d73 100755 --- a/Sources/CKFetchRecordsOperation.swift +++ b/Sources/CKFetchRecordsOperation.swift @@ -110,7 +110,7 @@ public class CKFetchRecordsOperation: CKDatabaseOperation { let recordID = strongSelf.recordIDs![index] strongSelf.progressed(recordID: recordID, progress: progress) - if let record = CKRecord(recordDictionary: recordDictionary) { + if let record = CKRecord(recordDictionary: recordDictionary, recordID: recordID) { strongSelf.recordIDsToRecords[record.recordID] = record // Call per record callback, not to be confused with finished diff --git a/Sources/CKRecord.swift b/Sources/CKRecord.swift index 859a963..2894863 100755 --- a/Sources/CKRecord.swift +++ b/Sources/CKRecord.swift @@ -126,7 +126,7 @@ public class CKRecord: NSObject { return"<\(type(of: self)); recordType = \(recordType);recordID = \(recordID); values = \(values)>" } - init?(recordDictionary: [String: Any]) { + init?(recordDictionary: [String: Any], recordID: CKRecordID? = nil) { guard let recordName = recordDictionary[CKRecordDictionary.recordName] as? String, let recordType = recordDictionary[CKRecordDictionary.recordType] as? String @@ -142,10 +142,14 @@ public class CKRecord: NSObject { zoneID = CKRecordZoneID(zoneName: CKRecordZoneDefaultName, ownerName: "_defaultOwner") } - let recordID = CKRecordID(recordName: recordName, zoneID: zoneID) - // self.init(recordType: recordType, recordID: recordID) + if let recordID = recordID { + self.recordID = recordID + } else { + let recordID = CKRecordID(recordName: recordName, zoneID: zoneID) + self.recordID = recordID + } + self.recordType = recordType - self.recordID = recordID // Parse Record Change Tag if let changeTag = recordDictionary[CKRecordDictionary.recordChangeTag] as? String { diff --git a/Sources/CKRecordID.swift b/Sources/CKRecordID.swift index c0446e2..a21b074 100755 --- a/Sources/CKRecordID.swift +++ b/Sources/CKRecordID.swift @@ -26,6 +26,10 @@ public class CKRecordID: NSObject { public var zoneID: CKRecordZoneID + public override func isEqual(_ object: Any?) -> Bool { + guard let other = object as? CKRecordID else { return false } + return self.recordName == other.recordName && self.zoneID == other.zoneID + } } extension CKRecordID { diff --git a/Sources/OpenCloudKit.swift b/Sources/OpenCloudKit.swift index e629525..90cc883 100755 --- a/Sources/OpenCloudKit.swift +++ b/Sources/OpenCloudKit.swift @@ -150,7 +150,11 @@ public class CKRecordZoneID: NSObject { self.init(zoneName: zoneName, ownerName: ownerName) } - + + public override func isEqual(_ object: Any?) -> Bool { + guard let other = object as? CKRecordZoneID else { return false } + return self.zoneName == other.zoneName && self.ownerName == other.ownerName + } }