首页 > 解决方案 > 为什么我会收到错误消息:“Auth”类型的值没有成员“useEmulator”

问题描述

我正在按照教程尝试设置 Firebase 模拟器套件。但是,我收到以下错误:“Auth”类型的值没有成员“useEmulator”。这是我的代码:

import UIKit
import Firebase
import IQKeyboardManager

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        FirebaseApp.configure()
        // code block used for local testing where error is showing
        let settings = Firestore.firestore().settings
        settings.host = "localhost:8080"
        settings.isPersistenceEnabled = false
        settings.isSSLEnabled = false
        Firestore.firestore().settings = settings
        Functions.functions().useFunctionsEmulator(origin: "http://localhost:5001")
        Auth.auth().useEmulator(withHost:"localhost", port:9099)
        //
        IQKeyboardManager.shared().isEnabled = true
        
        return true
    }

    // MARK: UISceneSession Lifecycle

    @available(iOS 13.0, *)
    func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
        // Called when a new scene session is being created.
        // Use this method to select a configuration to create the new scene with.
        return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
    }

    @available(iOS 13.0, *)
    func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
        // Called when the user discards a scene session.
        // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
        // Use this method to release any resources that were specific to the discarded scenes, as they will not return.
    }


}

播客文件:

# Uncomment the next line to define a global platform for your project
 platform :ios, '12.0'


target 'Pikit' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for Pikit
    pod 'Firebase'
    pod 'Firebase/Storage'
    pod 'Firebase/Auth'
    pod 'Firebase/Functions'
    pod 'Firebase/Firestore'
    pod 'Firebase/Analytics'
    pod 'Firebase/Messaging'
    pod 'Firebase/DynamicLinks'
    pod 'FirebaseUI', '~> 8.0'
    pod 'FirebaseUI/Google'
    pod 'FirebaseUI/Facebook'
    pod 'FirebaseUI/OAuth' # Used for Sign in with Apple, Twitter, etc
    pod 'FirebaseUI/Phone'
    pod 'IQKeyboardManager' # Auto move screen for keyboard
    pod 'SDWebImage', :modular_headers => true
    pod 'PureLayout'
  
end

我试图建立和清理我的文件夹,但没有奏效。我认为我没有将提供的代码放在正确的位置,但文档中没有说明它应该放在哪里。

标签: swiftfirebasefirebase-authenticationgoogle-cloud-functions

解决方案


如果它可以帮助任何人。Cocoapods 没有安装最新的 Firebase SDK。

在您的 Podfile 中:添加
min SDK:platform :ios, '14.0'
更改为pod 'FirebaseFirestoreSwift', '~> 7.0-beta'


推荐阅读