title: Unable to properly size SKScene when working with SwiftUI
body: <p>I am attempting to use <code>SpriteKit</code> with a <code>SwiftUI</code> based interface, but have encountered an issue when initializing my <code>SKScene</code>.</p>
  <p>First, my <code>UIViewRepresentable</code> that contains the <code>SKView</code> has been taken from a <a href="https://stackoverflow.com/questions/56615183/using-spritekit-inside-swiftui">similar question</a>:</p>
  <pre><code>struct SpriteKitContainer: UIViewRepresentable {
      let scene: SKScene
  
      func makeUIView(context: Context) -&gt; SKView {
          return SKView(frame: .zero)
      }
      
      func updateUIView(_ view: SKView, context: Context) {
          view.presentScene(scene)
      }
  }
  </code></pre>
  <p>A key piece here is that it requires the <code>SKScene</code> to be initialized prior to <code>SpriteKitContainer</code> being initialized.</p>
  <p>I currently have the following abbreviated snippet doing this:</p>
  <pre><code>import SwiftUI
  import SpriteKit
  
  struct GameView: View {
      @State private var isEnabled = true
      
      var body: some View {
          let tapGesture = TapGesture()
              .onEnded { value in }
          
          // This size is obviously wrong
          let size = UIScreen.main.bounds.size
          let scene = Scene(size: size)
          scene.scaleMode = .resizeFill
          
          return SpriteKitContainer(scene: scene)
              .disabled(!isEnabled)
              .frame(maxWidth: .infinity,
                     maxHeight: .infinity,
                     alignment: .center)
              .gesture(tapGesture)
              .padding(.all, 30)
      }
  }
  </code></pre>
  <p>I only include the <code>TapGesture</code> to show why the <code>body</code> is structured the way it is. With the code included, everything will work as expected, but the size used for the scene is obviously wrong (it fails to account for the padding, and navigation elements).</p>
  <p>However, I have not found any other way to obtain a size or frame at this point, and sending over a <code>.zero</code> size for the <code>Scene(size:)</code> call will not size it correctly either.</p>
  <p>My assumption is that I am missing some precursor step as I am still ramping up with SwiftUI. Otherwise, I could calculate a new <code>CGSize</code> given what I know, but that strikes me as the wrong approach here.</p>