How the App Starts

Where does an app begin?

You can write views all day, but something has to tell iOS which view appears when the user taps the PawWalk icon. That something is a struct conforming to the App protocol β€” the twin of View, one level up.

  • An App has a body too, but its type is some Scene, not some View. A scene is a chunk of UI the system manages β€” on iPhone, essentially "the app's window".
  • WindowGroup is the scene you'll use: "give my content a window to live in." Whatever view you put inside it becomes the root of everything on screen.
  • @main is an attribute that marks the entry point: "iOS, start here." Exactly one type per app gets it.

PawWalk's entire entry point is 14 lines. Here it is, for real: