How to wait for a closure completion before returning a value

It is possible (However make sure this is what you really want.).

You have to use something that will block a thread until a resource is available, like semaphores.

var foo: String {
    let semaphore = DispatchSemaphore(value: 0)
    var string = ""

    getSomethingAsynchronously { something in
        string = something
        semaphore.signal()
    }

    semaphore.wait()
    return string
}

Bare in mind that the thread you are working on will be blocked until the getSomethingAsynchronously is done.