【发布时间】:2021-03-11 19:28:25
【问题描述】:
我正在关注this 教程来尝试设置 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.
}
}
Pod 文件:
# 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
我尝试构建和清理我的文件夹,但没有奏效。我认为我没有将提供的代码放在正确的位置,但文档中没有说明它应该放在哪里。
【问题讨论】:
-
您是否安装了 Firebase/Auth pod?
-
@GarrenFitzenreiter 是的,我会编辑以包含我的 podfile。
-
抱歉花了这么长时间才回复,但我不知道为什么这么说,但我可以向你保证,我已经将该行添加到我的项目中的同一个地方,它让我建造的。
-
您使用的是最新版本的 Firebase Auth(我认为是 7.2.0)吗?可能是早期版本使用不同的方式启动模拟器。
-
您好,我遇到了同样的错误,您是如何解决的?
标签: swift firebase firebase-authentication google-cloud-functions