Group Group Group Group Group Group Group Group Group

Life cycle SwiftUI App has no SceneDelegate

I’m in Chapter 2. I wanted to initialize the color let constants in the SceneDelegate, but there wasn’t one. It seems that I’d changed Life cycle on the New, Project from UIKit App to SwiftUI app.

I think I’m good going forward, but can you briefly describe why there are two lifecycle options and whether there was an easier fix to picking the wrong one at the start than recreating the entire app? Is the new option documented anywhere in the forum for this book?

hi! Xcode 12 has an App instead of a SceneDelegate. ContentView() is in the WindowGroup closure. Just replace it there:

@main
struct RGBullsEyeApp: App {
  var body: some Scene {
    WindowGroup {
      ContentView(rGuess: 0.5, gGuess: 0.5, bGuess: 0.5)
    }
  }
}

We’re updating the book for Xcode 12 now.

Thank you. I’m looking forward to the new edition.