Xcode 13.2 Beta: Can only own code use the async/await in macos < 12.0

With Xcode 13.2 it is now possible to use async/await also in code prior to macos 12.0 (iOS....).

As I like this new pattern i have started to migrate existing code to this pattern and I have found out, that although you can use async/await in your own code, you cannot (yet?) call system libraries that adopt this pattern.

I have for example tried to replace URLSessions dataTask(with:completionHandler:) with the async version data(from, delegate) async throws -> (Data, URLResponse) but this fails with the error, that this function is only available on macos 12.0.

Am I missing something or is Apple planning to also add backward compatibility for older OS versions? Like this it is just half that funny.

Hope this helps:

https://www.swiftbysundell.com/articles/connecting-async-await-with-other-swift-code/

You can use concurrency prior to macOS 12.0 because it is a language feature, but not the macOS 12's frameworks (macOS feature). If you want to mix code of <12.0 and >12.0, you can use the example of that article to build your own function constructor.

Hi,

thanks for your answer.

Of course it is an idea to just use withCheckedThrowingContinuation(function:_:) to introduce my own async functions to existing functions with completions, but it just seems odd, that Apple just does not supply them out of the box. Maybe another beta will.

Xcode 13.2 Beta: Can only own code use the async/await in macos &lt; 12.0
 
 
Q