import Foundation func wait(for block: @escaping @Sendable () async -> Void) { let semaphore = DispatchSemaphore(value: 0) Task { await block() semaphore.signal() } semaphore.wait() }