Home > front end >  Module 'Swift' has no member named 'Task'
Module 'Swift' has no member named 'Task'

Time:04-11

I have created an enum named Task in my project. Now I want to use the Swift Task (Task interface definition in Xcode


Instead of explicitly writing out _Concurrency.Task in order to disambiguate everywhere, consider the following:

  1. You can create a typealias for the type (e.g. typealias SwiftTask = _Concurrency.Task) if you prefer your own Task type taking precedence, and don't want to rename it
  2. Alternatively, depending on whether it makes sense for your project (and is reasonable in context): this might be an opportunity to consider a more specific name for your type to possibly avoid both nominal and logical conflicts. async/await and Task are major new language/stdlib features that are going to be influential for a long time, so it may make sense to pick a less general word if the stdlib is going to be reserving that one going forward
  • Related