Skip to content

Commit

Permalink
Add UIApplicationDelegate to silence AppDelegateSwizzler error
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewheard committed May 9, 2024
1 parent 6e277f0 commit a394cf6
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions FirebaseVertexAI/Sample/VertexAISample/VertexAISampleApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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 {
Expand Down

0 comments on commit a394cf6

Please sign in to comment.