How To Show A SwiftUI Onboarding Screen Only When To App Launches For The First Time

I want to use onboarding screen in my project, and it is work but I want to use it just once time for app, I do not know how I will do it, is there any way?


struct ContentView: View {
  @State private var onboardinDone = false
  var data = OnboardingData.data
   
  var body: some View {
    Group {
      if !onboardinDone {
        OnboardingView(data: data, doneFunction: {
        
         
          print("done onboarding")
        })
      } else {
        MainScreen()
      }
    }
  }
   
  
}

struct ContentView_Previews: PreviewProvider {
  static var previews: some View {
    ContentView()
  }
}

Hey, did you find a working solution?

You need to persist onboardinDone and one way to do this is by using UserDefaults.

How To Show A SwiftUI Onboarding Screen Only When To App Launches For The First Time
 
 
Q