title: Error: 'async' call cannot occur in a property initializer
body: <p>I'm trying to place a <code>StateObject</code> <code>actor</code> whose initializer is <code>async</code> in an <code>App</code>, but I can't find a way to do that.</p>
  <p>Let's say I have this actor:</p>
  <pre class="lang-swift prettyprint-override"><code>actor Foo: ObservableObject {
      init() async {
          // ...
      }
  }
  </code></pre>
  <p>This results in the titular error:</p>
  <pre class="lang-swift prettyprint-override"><code>import SwiftUI
  
  struct MyApp: App {
      @StateObject
      var foo = await Foo() //  'async' call cannot occur in a property initializer
  
      var body: some Scene {
          // ...
      }
  }
  </code></pre>
  <p>This results in a similar error:</p>
  <pre class="lang-swift prettyprint-override"><code>import SwiftUI
  
  struct MyApp: App {
      @StateObject
      var foo: Foo
  
      init() async {
          _foo = .init(wrappedValue: await Foo()) //  'async' call in a function that does not support concurrency
      }
  
      var body: some Scene {
          // ...
      }
  }
  </code></pre>
  <p>And even these won't work:</p>
  <pre class="lang-swift prettyprint-override"><code>import SwiftUI
  
  struct MyApp: App {
      @StateObject
      var foo: Foo
  
      init() async {
          Task {
              self._foo = .init(wrappedValue: await Foo()) //  Mutation of captured parameter 'self' in concurrently-executing code
          }
      }
  
      var body: some Scene {
          // ...
      }
  }
  </code></pre>
  <pre class="lang-swift prettyprint-override"><code>import SwiftUI
  
  struct MyApp: App {
      @StateObject
      var foo: Foo
  
      init() async {
          Task { [self] in
              self._foo = .init(wrappedValue: await Foo()) //  Cannot assign to property: 'self' is an immutable capture
          }
      }
  
      var body: some Scene {
          // ...
      }
  }
  </code></pre>
  <p>It seems no matter what I do, I cannot have a <code>Foo</code> be a member of <code>MyApp</code>. What am I missing here? Surely this is possible.</p>
  <p>I run into the same problems with SwiftUI <code>View</code>s too, so any advice that works for both <code>View</code>s and <code>App</code>s would be spectacular!</p>