Skip to content

Commit

Permalink
fix for watchOS
Browse files Browse the repository at this point in the history
  • Loading branch information
mentrena committed Nov 8, 2021
1 parent f5e363f commit 1a1c040
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 33 deletions.
6 changes: 3 additions & 3 deletions SyncKit/Classes/CoreData/CoreDataAdapter+ModelAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ extension CoreDataAdapter {
}
}

@available(iOS 15.0, OSX 12, *)
@available(iOS 15.0, OSX 12, watchOS 8.0, *)
public func shareForRecordZone() -> CKShare? {
var record: CKShare?
privateContext.performAndWait {
Expand All @@ -331,7 +331,7 @@ extension CoreDataAdapter {
/// Store CKShare for the record zone.
/// - Parameters:
/// - share: `CKShare` object to save.
@available(iOS 15.0, OSX 12, *)
@available(iOS 15.0, OSX 12, watchOS 8.0, *)
public func saveShareForRecordZone(share: CKShare) {
privateContext.performAndWait {
self.saveShareForRecordZoneEntity(share: share)
Expand All @@ -340,7 +340,7 @@ extension CoreDataAdapter {
}

/// Delete existing `CKShare` for adapter's record zone.
@available(iOS 15.0, OSX 12, *)
@available(iOS 15.0, OSX 12, watchOS 8.0, *)
public func deleteShareForRecordZone() {
privateContext.performAndWait {
if let share = syncedEntityForRecordZoneShare() {
Expand Down
8 changes: 4 additions & 4 deletions SyncKit/Classes/CoreData/CoreDataAdapter+Private.swift
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ extension CoreDataAdapter {
return fetched?.first
}

@available(iOS 15.0, OSX 12, *)
@available(iOS 15.0, OSX 12, watchOS 8.0, *)
func syncedEntityForRecordZoneShare() -> QSSyncedEntity? {
let fetched = try? self.privateContext.executeFetchRequest(entityName: "QSSyncedEntity",
predicate: NSPredicate(format: "identifier == %@", CKRecordNameZoneWideShare),
Expand Down Expand Up @@ -282,7 +282,7 @@ extension CoreDataAdapter {
qsRecord.encodedRecord = QSCoder.shared.encode(share) as NSData
}

@available(iOS 15.0, OSX 12, *)
@available(iOS 15.0, OSX 12, watchOS 8.0, *)
func saveShareForRecordZoneEntity(share: CKShare) {
var entity = syncedEntityForRecordZoneShare()
var qsRecord: QSRecord!
Expand Down Expand Up @@ -362,7 +362,7 @@ extension CoreDataAdapter {
record[attributeName] = transformed
} else if let encrypted = encryptedFields,
encrypted.contains(attributeName) {
if #available(iOS 15, OSX 12, *) {
if #available(iOS 15, OSX 12, watchOS 8.0, *) {
record.encryptedValues[attributeName] = value as? CKRecordValueProtocol
}
// Else not possible, since the EncryptedObject protocol is only declared for CloudKit versions that support encryption
Expand Down Expand Up @@ -522,7 +522,7 @@ extension CoreDataAdapter {

if let encrypted = encryptedFields,
encrypted.contains(attributeName) {
if #available(iOS 15, OSX 12, *) {
if #available(iOS 15, OSX 12, watchOS 8.0, *) {
object.setValue(record.encryptedValues[attributeName], forKey: attributeName)
}
// Else not possible, since the EncryptedObject protocol is only declared for CloudKit versions that support encryption
Expand Down
2 changes: 1 addition & 1 deletion SyncKit/Classes/CoreData/CoreDataAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ extension CoreDataAdapter {
}

private func setupEncryptedFields() {
if #available(iOS 15, OSX 12, *) {
if #available(iOS 15, OSX 12, watchOS 8.0, *) {
targetContext.performAndWait {
guard let entities = self.targetContext.persistentStoreCoordinator?.managedObjectModel.entities else { return }
for entityDescription in entities {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ import CloudKit
- Parameter zoneID The record zone ID.
- Returns: `CKShare` stored for the given object.
*/
@available(iOS 15.0, OSX 12, *)
@available(iOS 15.0, OSX 12, watchOS 8.0, *)
@objc func share(forRecordZoneID zoneID: CKRecordZone.ID) -> CKShare? {
guard let modelAdapter = modelAdapter(forRecordZoneID: zoneID) else {
return nil
Expand All @@ -259,7 +259,7 @@ import CloudKit

This method should be called by your `UICloudSharingControllerDelegate`, when `cloudSharingControllerDidSaveShare` is called.
*/
@available(iOS 15.0, OSX 12, *)
@available(iOS 15.0, OSX 12, watchOS 8.0, *)
@objc func cloudSharingControllerDidSaveShare(_ share: CKShare, forRecordZoneID zoneID: CKRecordZone.ID) {
guard let modelAdapter = modelAdapter(forRecordZoneID: zoneID) else {
return
Expand All @@ -273,7 +273,7 @@ import CloudKit
- zoneID The record zone ID.
This method should be called by your `UICloudSharingControllerDelegate`, when `cloudSharingControllerDidStopSharing` is called.
*/
@available(iOS 15.0, OSX 12, *)
@available(iOS 15.0, OSX 12, watchOS 8.0, *)
@objc func cloudSharingControllerDidStopSharing(forRecordZoneID zoneID: CKRecordZone.ID) {
guard let modelAdapter = modelAdapter(forRecordZoneID: zoneID) else {
return
Expand All @@ -291,7 +291,7 @@ import CloudKit
- completion: Closure that gets called with an optional error when the operation is completed.

*/
@available(iOS 15.0, OSX 12, *)
@available(iOS 15.0, OSX 12, watchOS 8.0, *)
@objc func share(recordZoneID: CKRecordZone.ID, publicPermission: CKShare.ParticipantPermission, participants: [CKShare.Participant], completion: ((CKShare?, Error?) -> ())?) {
guard !syncing else {
completion?(nil, CloudKitSynchronizer.SyncError.alreadySyncing)
Expand Down Expand Up @@ -356,7 +356,7 @@ import CloudKit
- recordZoneID The ID of the record zone to unshare.
- completion Closure that gets called on completion.
*/
@available(iOS 15.0, OSX 12, *)
@available(iOS 15.0, OSX 12, watchOS 8.0, *)
@objc func removeShare(recordZoneID: CKRecordZone.ID, completion: ((Error?) -> ())?) {
guard !syncing else {
completion?(CloudKitSynchronizer.SyncError.alreadySyncing)
Expand Down
6 changes: 3 additions & 3 deletions SyncKit/Classes/QSSynchronizer/ModelAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@ public extension Notification.Name {
@available(iOS 10.0, OSX 10.12, *) func deleteShare(for object: AnyObject)

/// - Returns: CKShare for the adapter's record zone, if one exists.
@available(iOS 15.0, OSX 12, *) func shareForRecordZone() -> CKShare?
@available(iOS 15.0, OSX 12, watchOS 8.0, *) func shareForRecordZone() -> CKShare?

/// Store CKShare for the record zone.
/// - Parameters:
/// - share: `CKShare` object to save.
@available(iOS 15.0, OSX 12, *) func saveShareForRecordZone(share: CKShare)
@available(iOS 15.0, OSX 12, watchOS 8.0, *) func saveShareForRecordZone(share: CKShare)

/// Delete existing `CKShare` for adapter's record zone.
@available(iOS 15.0, OSX 12, *) func deleteShareForRecordZone()
@available(iOS 15.0, OSX 12, watchOS 8.0, *) func deleteShareForRecordZone()

/// Returns a list of records for the given object and any parent records, recursively.
/// - Parameter object: Model object.
Expand Down
2 changes: 1 addition & 1 deletion SyncKit/Classes/QSSynchronizer/PrimaryKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import Foundation
/**
* Can be adopted by classes to use CloudKit encryption for some fields
*/
@available(iOS 15, OSX 12, *)
@available(iOS 15, OSX 12, watchOS 8.0, *)
@objc public protocol EncryptedObject: AnyObject {

/// Name of the fields that should use encryption
Expand Down
16 changes: 8 additions & 8 deletions SyncKit/Classes/Realm/RealmAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ struct ObjectUpdate {
}

func setupEncryptedFields() {
if #available(iOS 15, OSX 12, *) {
if #available(iOS 15, OSX 12, watchOS 8.0, *) {
targetRealmConfiguration.objectClasses?.forEach { objectType in
if let objectType = objectType as? RLMObject.Type,
let encryptedType = objectType as? EncryptedObject.Type {
Expand Down Expand Up @@ -519,7 +519,7 @@ struct ObjectUpdate {
return getSyncedEntity(objectIdentifier: identifier, realm: realm)
}

@available(iOS 15, OSX 12, *)
@available(iOS 15, OSX 12, watchOS 8.0, *)
func syncedEntityForRecordZoneShare(realm: RLMRealm) -> SyncedEntity? {
return getSyncedEntity(objectIdentifier: CKRecordNameZoneWideShare, realm: realm)
}
Expand Down Expand Up @@ -633,7 +633,7 @@ struct ObjectUpdate {

if let encrypted = entityEncryptedFields[syncedEntity.entityType],
encrypted.contains(key) {
if #available(iOS 15, OSX 12, *) {
if #available(iOS 15, OSX 12, watchOS 8.0, *) {
object.setValue(record.encryptedValues[key], forKey: key)
}
} else {
Expand Down Expand Up @@ -780,7 +780,7 @@ struct ObjectUpdate {

qsRecord?.encodedRecord = encodedRecord(share, onlySystemFields: false)
}
@available(iOS 15, OSX 12, *)
@available(iOS 15, OSX 12, watchOS 8.0, *)
func saveShareForRecordZone(share: CKShare, realmProvider: RealmProvider) {
var entity = syncedEntityForRecordZoneShare(realm: realmProvider.persistenceRealm)
var qsRecord: Record!
Expand Down Expand Up @@ -907,7 +907,7 @@ struct ObjectUpdate {

if let encrypted = encryptedFields,
encrypted.contains(property.name) {
if #available(iOS 15, OSX 12, *) {
if #available(iOS 15, OSX 12, watchOS 8.0, *) {
record.encryptedValues[property.name] = object!.value(forKey: property.name) as? CKRecordValue
}
} else {
Expand Down Expand Up @@ -1360,7 +1360,7 @@ struct ObjectUpdate {
return records ?? []
}

@available(iOS 15.0, OSX 12, *)
@available(iOS 15.0, OSX 12, watchOS 8.0, *)
public func shareForRecordZone() -> CKShare? {
guard realmProvider != nil else {
return nil
Expand All @@ -1380,7 +1380,7 @@ struct ObjectUpdate {
/// Store CKShare for the record zone.
/// - Parameters:
/// - share: `CKShare` object to save.
@available(iOS 15.0, OSX 12, *)
@available(iOS 15.0, OSX 12, watchOS 8.0, *)
public func saveShareForRecordZone(share: CKShare) {
guard realmProvider != nil else {
return
Expand All @@ -1394,7 +1394,7 @@ struct ObjectUpdate {
}

/// Delete existing `CKShare` for adapter's record zone.
@available(iOS 15.0, OSX 12, *)
@available(iOS 15.0, OSX 12, watchOS 8.0, *)
public func deleteShareForRecordZone() {
guard realmProvider != nil else {
return
Expand Down
16 changes: 8 additions & 8 deletions SyncKit/Classes/RealmSwift/RealmSwiftAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public class RealmSwiftAdapter: NSObject, ModelAdapter {
}

func setupEncryptedFields() {
if #available(iOS 15, OSX 12, *) {
if #available(iOS 15, OSX 12, watchOS 8.0, *) {
targetRealmConfiguration.objectTypes?.forEach { objectType in
if let encryptedEntity = objectType as? EncryptedObject.Type {
entityEncryptedFields[objectType.className()] = Set(encryptedEntity.encryptedFields())
Expand Down Expand Up @@ -530,7 +530,7 @@ public class RealmSwiftAdapter: NSObject, ModelAdapter {
return getSyncedEntity(objectIdentifier: identifier, realm: realm)
}

@available(iOS 15, OSX 12, *)
@available(iOS 15, OSX 12, watchOS 8.0, *)
func syncedEntityForRecordZoneShare(realm: Realm) -> SyncedEntity? {
return getSyncedEntity(objectIdentifier: CKRecordNameZoneWideShare, realm: realm)
}
Expand Down Expand Up @@ -643,7 +643,7 @@ public class RealmSwiftAdapter: NSObject, ModelAdapter {

if let encrypted = entityEncryptedFields[syncedEntity.entityType],
encrypted.contains(key) {
if #available(iOS 15, OSX 12, *) {
if #available(iOS 15, OSX 12, watchOS 8.0, *) {
object.setValue(record.encryptedValues[key], forKey: key)
}
} else {
Expand Down Expand Up @@ -794,7 +794,7 @@ public class RealmSwiftAdapter: NSObject, ModelAdapter {
qsRecord?.encodedRecord = encodedRecord(share, onlySystemFields: false)
}

@available(iOS 15, OSX 12, *)
@available(iOS 15, OSX 12, watchOS 8.0, *)
func saveShareForRecordZone(share: CKShare, realmProvider: RealmProvider) {
var entity = syncedEntityForRecordZoneShare(realm: realmProvider.persistenceRealm)
var qsRecord: Record!
Expand Down Expand Up @@ -931,7 +931,7 @@ public class RealmSwiftAdapter: NSObject, ModelAdapter {

if let encrypted = encryptedFields,
encrypted.contains(property.name) {
if #available(iOS 15, OSX 12, *) {
if #available(iOS 15, OSX 12, watchOS 8.0, *) {
record.encryptedValues[property.name] = object.value(forKey: property.name) as? CKRecordValue
}
} else {
Expand Down Expand Up @@ -1384,7 +1384,7 @@ public class RealmSwiftAdapter: NSObject, ModelAdapter {
return records ?? []
}

@available(iOS 15.0, OSX 12, *)
@available(iOS 15.0, OSX 12, watchOS 8.0, *)
public func shareForRecordZone() -> CKShare? {
guard realmProvider != nil else {
return nil
Expand All @@ -1404,7 +1404,7 @@ public class RealmSwiftAdapter: NSObject, ModelAdapter {
/// Store CKShare for the record zone.
/// - Parameters:
/// - share: `CKShare` object to save.
@available(iOS 15.0, OSX 12, *)
@available(iOS 15.0, OSX 12, watchOS 8.0, *)
public func saveShareForRecordZone(share: CKShare) {
guard realmProvider != nil else {
return
Expand All @@ -1418,7 +1418,7 @@ public class RealmSwiftAdapter: NSObject, ModelAdapter {
}

/// Delete existing `CKShare` for adapter's record zone.
@available(iOS 15.0, OSX 12, *)
@available(iOS 15.0, OSX 12, watchOS 8.0, *)
public func deleteShareForRecordZone() {
guard realmProvider != nil else {
return
Expand Down

0 comments on commit 1a1c040

Please sign in to comment.