Skip to content

Instantly share code, notes, and snippets.

@foxicode
Created August 18, 2023 23:07
Show Gist options
  • Save foxicode/4c6852ff2f9c4436878bf5e4ca59e661 to your computer and use it in GitHub Desktop.
Save foxicode/4c6852ff2f9c4436878bf5e4ca59e661 to your computer and use it in GitHub Desktop.
Using AppDelegate in SwiftUI
import SwiftUI
@main
struct Swift2TestApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
print("App launched")
return true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment