Skip to content

Commit 4985f23

Browse files
fix(build): resolve concurrent-capture errors under Xcode 15.4
Two more latent compile errors surfaced now that Build & Test runs: - NFCManager.tagReaderSession captured the weak 'self' var inside a concurrently-executing Task { @mainactor } (lines 134/135). Bind it once with 'guard let self' so the Task captures an immutable reference. - ContactsManager.fetchMTRXContacts captured the mutable 'contacts' var inside a Task { @mainactor }. Snapshot it into a 'let' before the Task and return that. Both are 'reference to captured var ... in concurrently-executing code' errors under the CI toolchain (Swift 5.10); behavior is unchanged. Co-authored-by: Dardan <ItsDardanRexhepi@users.noreply.github.com>
1 parent 73ee916 commit 4985f23

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

Apple/Connectivity/NFCManager.swift

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,10 @@ extension NFCManager: NFCTagReaderSessionDelegate {
116116
guard let tag = tags.first else { return }
117117

118118
session.connect(to: tag) { [weak self] error in
119+
guard let self else { return }
119120
if let error = error {
120-
self?.scanContinuation?.resume(throwing: NFCError.connectionFailed(error.localizedDescription))
121-
self?.scanContinuation = nil
121+
self.scanContinuation?.resume(throwing: NFCError.connectionFailed(error.localizedDescription))
122+
self.scanContinuation = nil
122123
return
123124
}
124125

@@ -131,12 +132,12 @@ extension NFCManager: NFCTagReaderSessionDelegate {
131132
)
132133

133134
Task { @MainActor in
134-
self?.lastScannedPayload = payload
135-
self?.isScanning = false
135+
self.lastScannedPayload = payload
136+
self.isScanning = false
136137
}
137138

138-
self?.scanContinuation?.resume(returning: payload)
139-
self?.scanContinuation = nil
139+
self.scanContinuation?.resume(returning: payload)
140+
self.scanContinuation = nil
140141
session.invalidate(errorMessage: "")
141142
}
142143
}

Apple/Interaction/ContactsManager.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ final class ContactsManager: ObservableObject {
6969
}
7070
}
7171

72-
Task { @MainActor in mtrxContacts = contacts }
73-
return contacts
72+
let resolved = contacts
73+
Task { @MainActor in mtrxContacts = resolved }
74+
return resolved
7475
}
7576

7677
// MARK: - Search

0 commit comments

Comments
 (0)