Fixing the “Async call in a function that doesn’t support concurrency” error in Swift

The error message may also say “Cannot pass function of type ‘() async -> Void’ to parameter expecting synchronous function type”.

Why am I getting this error?

You are using Swift’s async await syntax and calling an async function in a function that does not support async await. If you have the following function that calls an async function:

You are going to get the “Async call in a function that doesn’t support concurrency” build error because myFunction is not an async function.

Apple added async await support to Swift in 2021 so the support is relatively new. Many of Apple’s frameworks do not support the new async await syntax.

Apple’s ASWebAuthenticationSession class, which apps use to log into websites, does not support async await. When you create an instance of ASWebAuthenticationSession, you supply a completion handler that runs after a successful login. If you make an async function call in the completion handler, you’ll get the “Async call in a function that doesn’t support concurrency” build error.

Ways to fix the error

The most common way to fix the error is to place the call to the async function in a Task block.

If the error occurs in a function you wrote, you can fix the error by marking that function as async.

Don’t forget to add await when calling the function you marked as async.

Do you want to learn how to fix errors in your Swift code?

I’m writing a book, Fixing Swift Code, that will teach you how to find and fix errors in your Swift code so your projects will build successfully and run without crashing. Some of the things you’ll learn in the book include the following:

  • What Xcode’s build error messages really mean
  • How to fix your code so your project builds
  • How to find where your app crashes
  • The most common causes of app crashes and how to fix them

You can learn more about the book and get a discount on the book when it ships by going to the book’s homepage.