0
  • Xcode version: 12.5.1
  • Firebase SDK version: 8.5.0
  • Installation method: Swift Package Manager
  • Firebase Component: App Check

I'm getting error using the sample code in app delegate (Step 3 here: Setup Firebase App Check on iOS):

"Cannot find type 'AppCheckProviderFactory' in scope"

First, I tried importing FirebaseAppCheck, but that wasn't recognized. I can import Firebase fine (and I'm using that in my app already), but that doesn't seem get me hooked into App Check. When I look in the downloaded Firebase package, I see FirebaseAppCheck.

I reset my package cache and cleaned the build folder, neither of which resolved the issue. Is App Check intended to work with SPM, or should I be importing the framework manually? Or, (probably more likely), am I missing something obvious here?

Following code returns two errors: Cannot find type 'AppCheckProviderFactory' in scope & Cannot find type 'AppCheckProvider' in scope.

import Firebase

class SimpleAppCheckProviderFactory: NSObject, AppCheckProviderFactory {
  func createProvider(with app: FirebaseApp) -> AppCheckProvider? {
    return AppAttestProvider(app: app)
  }
}

If anyone can point in the right direction, I'd greatly appreciate it.

Anonymous
  • 11
  • 3

2 Answers2

0

Try importing App Check Library, ex: import FirebaseAppCheck. Tested via SwiftPM.

Anonymous
  • 11
  • 3
0
import SwiftUI
import Firebase
import FirebaseCore
import FirebaseAppCheck

final class AppDelegate: NSObject, UIApplicationDelegate {
    let providerFactory = SweetAppCheckProviderFactory()
    let providerFactory = AppCheckDebugProviderFactory() // for dev
    
    func application(_ application: UIApplication,
                     didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
        
        AppCheck.setAppCheckProviderFactory(providerFactory)
        
        FirebaseApp.configure()
        return true
    }
}

@main
struct SweetApp: App {
    @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
    
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

class SweetAppCheckProviderFactory: NSObject, AppCheckProviderFactory {
    func createProvider(with app: FirebaseApp) -> AppCheckProvider? {
        return AppAttestProvider(app: app)
    }
}
cbear84
  • 486
  • 4
  • 13