# Why "error: cannot find 'Task' in scope" in Xcode Playground?

**URL:** <https://forums.swift.org/t/why-error-cannot-find-task-in-scope-in-xcode-playground/50507>\
**Category:** Using Swift\
**Created:** [July 17, 2021, 5:25pm UTC](https://forums.swift.org/t/why-error-cannot-find-task-in-scope-in-xcode-playground/50507 "2021-07-17T17:25:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![young](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/young/32/7878_2.png) [@young](https://forums.swift.org/u/young)\
**Post date:** [July 17, 2021, 5:25pm UTC](https://forums.swift.org/t/why-error-cannot-find-task-in-scope-in-xcode-playground/50507/1 "2021-07-17T17:25:36Z")

</div>

In Xcode Version 13.0 beta 3 (13A5192i), I just paste this example:

```swift
@MainActor
class Test {
    fileprivate var value: Int?

    func tryMe() {
        Task {
            self.value = nil
        }
    }
}

```

from [Why don't I need an await in this example? - #2 by nikitamounier](https://forums.swift.org/t/why-dont-i-need-an-await-in-this-example/50502/2)

and get these compile error:

```swift
 **Playground execution failed:**
 
 **error: MainActorInheritActorContext.xcplaygroundpage:3:1: error: unknown attribute 'MainActor'**
 
 **@MainActor**
 
 **^**
 
 **error: MainActorInheritActorContext.xcplaygroundpage:8:9: error: cannot find 'Task' in scope**
 
 **Task {**
 
 **^~~~**

```

Edit: this compiles fine in a iOS project. So why Xcode Playground not compile the same code?

---

<div class="post-metadata">

**Author:** ![1-877-547-7272](https://avatars.discourse-cdn.com/v4/letter/1/278dde/32.png) [@1-877-547-7272](https://forums.swift.org/u/1-877-547-7272)\
**Post date:** [July 17, 2021, 11:26pm UTC](https://forums.swift.org/t/why-error-cannot-find-task-in-scope-in-xcode-playground/50507/2 "2021-07-17T23:26:14Z")

</div>

Swift playgrounds don’t seem to fully support concurrency yet.

You can use `import _Concurrency` to enable most features, but some features may be missing. For example, I don’t think async let is usable with this method.

---

<div class="post-metadata">

**Author:** ![young](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/young/32/7878_2.png) [@young](https://forums.swift.org/u/young)\
**Post date:** [July 18, 2021, 4:22am UTC](https://forums.swift.org/t/why-error-cannot-find-task-in-scope-in-xcode-playground/50507/3 "2021-07-18T04:22:21Z")

</div>

I'll just use iOS or macOS project to experiment with async/await then.

Thanks!
