DEV Community

Cover image for Sketch Note: SwiftUI App Structure
Amarildo Lucas
Amarildo Lucas

Posted on

Sketch Note: SwiftUI App Structure

The SwiftUI App protocol looks simpler but is decisive for your applications' structure and organization.

This sketch note shares a general look at the parts involved while implementing your app's entry point.

Sketch Note: SwiftUI App Structure

Things to take in mind:

1. The App protocol represents structure and behavior.

2. The body is the content and can define scenes.

3. Scene acts as the root view of the view hierarchy and can be more than one.

4. The @main initialize and call the main() method which runs your app.

5. The init() runs by default.

6. You can have multiple scenes whose lifecycles will be managed by the system.

I hope this sketch note is helpful to you.

Top comments (1)

sergeyleschev profile image
Sergey Leschev

Great sketch note! The SwiftUI App protocol is indeed a crucial component in organizing and structuring SwiftUI applications. As you have pointed out, it may seem simpler than other aspects of the framework, but it plays a decisive role in ensuring a well-organized and scalable app.

It's worth noting that we use the SwiftUI App protocol for various tasks, such as initializing the app, setting up the app's lifecycle, managing the app's state, and defining the app's views and window hierarchy. Overall, this sketch note is a helpful reminder of the importance of the SwiftUI App protocol and how it contributes to building robust and maintainable SwiftUI applications.