Sync Over Async (ARCH9023)
Key swift.async.sync-over-async · Severity warning · Category async
Flags DispatchSemaphore.wait / DispatchGroup.wait / DispatchQueue.sync used to block on asynchronous work - deadlocks on the main thread and starves the cooperative pool.
Incorrect
Section titled “Incorrect”let semaphore = DispatchSemaphore(value: 0)Task { result = try await load(); semaphore.signal() }semaphore.wait()Correct
Section titled “Correct”let result = try await load()Propagate async up to the caller instead of blocking on it.