Hi,
I know it's an old question, but in case somebody faces the same problem. You can use method swizzling to address this issue.
private let swizzling: (CKRecord.Type) -> Void = { record in
guard let originalMethod = class_getInstanceMethod(record, #selector(getter: CKRecord.recordChangeTag)),
let swizzledMethod = class_getInstanceMethod(record, #selector(CKRecord.swizzledRecordChangeTag))
else { return }
method_exchangeImplementations(originalMethod, swizzledMethod)
}
extension CKRecord {
class func doBadSwizzleStuff() {
swizzling(self)
}
@objc func swizzledRecordChangeTag() -> String? {
"123"
}
}
And then call at your test setup: CKRecord.doBadSwizzleStuff()
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags: