diff --git a/FirebaseVertexAI/Sample/VertexAISample/VertexAISampleApp.swift b/FirebaseVertexAI/Sample/VertexAISample/VertexAISampleApp.swift index 1da675f21cc..f675f77a423 100644 --- a/FirebaseVertexAI/Sample/VertexAISample/VertexAISampleApp.swift +++ b/FirebaseVertexAI/Sample/VertexAISample/VertexAISampleApp.swift @@ -16,9 +16,10 @@ import FirebaseAppCheck import FirebaseCore import SwiftUI -@main -struct VertexAISampleApp: App { - init() { +class AppDelegate: NSObject, UIApplicationDelegate { + func application(_ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication + .LaunchOptionsKey: Any]? = nil) -> Bool { // Recommendation: Protect your Vertex AI API resources from abuse by preventing unauthorized // clients using App Check; see https://firebase.google.com/docs/app-check#get_started. AppCheck.setAppCheckProviderFactory(AppCheckNotConfiguredFactory()) @@ -27,12 +28,20 @@ struct VertexAISampleApp: App { if let firebaseApp = FirebaseApp.app(), firebaseApp.options.projectID == "mockproject-1234" { guard let bundleID = Bundle.main.bundleIdentifier else { fatalError() } - fatalError("You must create and/or download a valid `GoogleService-Info.plist` file for" - + " \(bundleID) from https://console.firebase.google.com to run this sample. Replace the" - + " existing `GoogleService-Info.plist` file in the `FirebaseVertexAI/Sample` directory" - + " with this new file.") + fatalError(""" + You must create and/or download a valid `GoogleService-Info.plist` file for \(bundleID) from \ + https://console.firebase.google.com to run this sample. Replace the existing \ + `GoogleService-Info.plist` file in the `FirebaseVertexAI/Sample` directory with this new file. + """) } + + return true } +} + +@main +struct VertexAISampleApp: App { + @UIApplicationDelegateAdaptor var appDelegate: AppDelegate var body: some Scene { WindowGroup {