Application LifeCycle in SwiftUI in Xcode 12

Updated 29 December 2020

Save

Application LifeCycle in SwiftUI in Xcode 12

Understanding Application LifeCycle in SwiftUI in Xcode 12 of the App is very important as it help in performing various operation with the change of state of the App.

With the introduction of iOS 13, there is introduction to the Scene delegate for managing the multiple scene in iOS Application.

In iOS 14 App Lifecycle comes up with the @main method for complete cycle.

In new App cycle we are having App protocol. So we have to use some Scene as it is a  type of associated Type in App protocol.

 

 

The @main attribute in the App LifeCycle is introduced with the Xcode 12 and swift 5.3.

The App Protocol is responsible for triggering  the @main method that further launches the IOS Application.

WindowGroup is a scene container that holds the views in SwiftUI.

In Application Lifecycle in SwiftUI in Xcode 12 we are using struct which help in spending up the execution of the App with SwiftUI.

In Earlier version we are using App delegate and  Scene delegate for triggering some operation with the change of the state of the App.

 

AppDelegate in App Life Cycle

We can also use the App delegate and scene delegate in our App Life cycle.

Therefore we have to include property wrapper for it and conform to the protocol required for its working.

The AppDelegate functions plays a very important role in configuring the a lot of things with the launch of the application.

In order to use the AppDelegate functions we have a property wrapper called UiApplicationDelegateAdaptor . It help in creating an instance of AppDelegate in our SwiftUI App Cycle.

In Conclusion

SwiftUI App lifecycle is very simple and help in injecting the required functionality of AppDelegate and Scene delegate as per requirement of your Application.

Please refer to the Apple docs here.

It help in speed up the development.In other words it is simple and short.

Thanks for reading my Blog. Please refer to the link for other blog here.

 

 

author
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Start a Project


    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home