diff --git a/Package.swift b/Package.swift index e5b99f6..4a90596 100644 --- a/Package.swift +++ b/Package.swift @@ -43,7 +43,7 @@ let infoPListChecker = add(moduleName: "InfoPListChecker", includesTest: false, // MARK: - Modules - Primary let async = add(moduleName: "Async", includesTest: false, swiftLanguageMode: .v5) let core = add(moduleName: "Core", dependencies: [assertServices, infoPListChecker], includesTest: true, swiftLanguageMode: .v6) -let nativeTag = add(moduleName: "NativeTag", dependencies: [core], includesTest: true, swiftLanguageMode: .v5) +let nativeTag = add(moduleName: "NativeTag", dependencies: [core], includesTest: true, swiftLanguageMode: .v6) add(moduleName: "NDEFMessage", dependencies: [core], includesTest: true, swiftLanguageMode: .v5) add(moduleName: "NDEFTag", dependencies: [core], includesTest: true, swiftLanguageMode: .v5) diff --git a/Sources/NativeTag/NFCNativeTagReaderCallBackHandleObject.swift b/Sources/NativeTag/NFCNativeTagReaderCallBackHandleObject.swift index 94325e1..160df2a 100644 --- a/Sources/NativeTag/NFCNativeTagReaderCallBackHandleObject.swift +++ b/Sources/NativeTag/NFCNativeTagReaderCallBackHandleObject.swift @@ -48,21 +48,32 @@ extension NFCNativeTagReaderCallBackHandleObject: NativeTag.Reader.Delegate { } public nonisolated func tagReaderSession(_ session: TagType.Reader.Session, didDetect tags: TagType.ReaderDetectObject) { + let tags = NFCTags(tags: tags) Task(priority: taskPriority) { await didDetect(tags: tags) } } } +extension NFCNativeTagReaderCallBackHandleObject { + struct NFCTags: Sendable { + nonisolated(unsafe) let base: TagType.ReaderDetectObject + + init(tags: TagType.ReaderDetectObject) { + self.base = tags + } + } +} + extension NFCNativeTagReaderCallBackHandleObject { func didBecomeActive() async { await didBecomeActiveHandler(reader as! TagType.Reader.AfterBeginProtocol) } - func didDetect(tags: TagType.ReaderDetectObject) async { + func didDetect(tags: NFCTags) async { let result: TagType.DetectResult do { - result = try await didDetectHandler(reader as! TagType.ReaderProtocol, tags) + result = try await didDetectHandler(reader as! TagType.ReaderProtocol, tags.base) } catch { result = .failure(with: error) } diff --git a/Sources/NativeTag/NFCNativeTagReaderProtocol.swift b/Sources/NativeTag/NFCNativeTagReaderProtocol.swift index cf8e0bd..ffbd340 100644 --- a/Sources/NativeTag/NFCNativeTagReaderProtocol.swift +++ b/Sources/NativeTag/NFCNativeTagReaderProtocol.swift @@ -7,7 +7,7 @@ public protocol NFCNativeTagReaderProtocol: NFCReaderAfterBeginProtocol { #if canImport(CoreNFC) - func connect(to tag: NFCTag) async throws + func connect(to tag: sending NFCTag) async throws #endif } diff --git a/Tests/NativeTagTests/NativeTagTests.swift b/Tests/NativeTagTests/NativeTagTests.swift index 060f9c2..40573c2 100644 --- a/Tests/NativeTagTests/NativeTagTests.swift +++ b/Tests/NativeTagTests/NativeTagTests.swift @@ -129,7 +129,7 @@ final class NativeTagTests: XCTestCase { let object = tagReaderDelegate as! NFCNativeTagReaderCallBackHandleObject await object.didBecomeActive() - await object.didDetect(tags: []) + await object.didDetect(tags: .init(tags: [])) await fulfillment(of: [didBecomeActiveExpectation, didInvalidateExpectation, didDetectExpectation], timeout: 0.01) #else