From 3b68b7902dc4c26754101bd3e690351b7fc55561 Mon Sep 17 00:00:00 2001 From: nkalvi Date: Sun, 23 Jul 2023 21:50:41 -0700 Subject: [PATCH 1/2] Adopt to changes in iOS17+ `Identifiable` conformance is added to iOS17 (and macOS) betas with `id: UUID { get }`. --- Demo/Views/ContactView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Demo/Views/ContactView.swift b/Demo/Views/ContactView.swift index b58948b..4239074 100644 --- a/Demo/Views/ContactView.swift +++ b/Demo/Views/ContactView.swift @@ -9,7 +9,7 @@ struct ContactView: View { @State private var error: Error? // We just pass along the identifier and then lets the property wrapper handle the fetch and observation - init(identifier: CNContact.ID) { + init(identifier: String) { _contact = FetchContact( idenfifier: identifier, keysToFetch: .allExcludingNote From 71dfb8809b0f557356cb12b4d88040179d1dd851 Mon Sep 17 00:00:00 2001 From: nkalvi Date: Sun, 23 Jul 2023 22:00:14 -0700 Subject: [PATCH 2/2] Adopt to changes in iOS17, macOS14 Identifiable conformance added to Contacts in iOS17, macOS14 --- Sources/Connections/Support/Identifiable.swift | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Sources/Connections/Support/Identifiable.swift b/Sources/Connections/Support/Identifiable.swift index f2b297a..2ed0f9c 100644 --- a/Sources/Connections/Support/Identifiable.swift +++ b/Sources/Connections/Support/Identifiable.swift @@ -1,8 +1,14 @@ import Foundation import Contacts -extension CNContact { - public var id: String { identifier } +@available(iOS, obsoleted: 16, message: "Contacts module includes it in iOS17+, macOS14+") +@available(macOS, obsoleted: 14, message: "Contacts module includes it in iOS17+, macOS14+") +extension CNContact: Identifiable { + public typealias ID = UUID + public var id: UUID { + UUID(uuidString: identifier.replacingOccurrences(of: ":ABPerson", with: ""))! + } + } extension CNGroup: Identifiable {