iosswiftiphoneasync-awaitswift-playground

'Task' cannot be constructed because it has no accessible initializers


I'm trying new Swift 5.5 await async features and I get that compilation error when I try this in a Playground:

let task1 = Task {
    // ...
}

'Task' cannot be constructed because it has no accessible initializers

I got the example from https://www.hackingwithswift.com/articles/233/whats-new-in-swift-5-5

Any idea?


Solution

  • It looks like the current syntax is async { ... } instead of Task { ... } with the intention that the Task syntax is to be used in some future build.