[英]Cannot call value of non-function type 'GIDSignIn'
我正在嘗試在我的應用中實現谷歌登錄。 但問題是當我將這行代碼添加到我的 App.swift 文件時,我遇到了一個錯誤。 我試圖從sharedInstance
中刪除()
但如果我這樣做,我會收到另一個錯誤( Value of type 'GIDSignIn' has no member 'clientID'
)。 我是 swift 和 swiftUI 的初學者
錯誤:
Cannot call value of non-function type 'GIDSignIn'
代碼行:
GIDSignIn.sharedInstance.clientID = FirebaseApp.app()?.options.clientID
我的 App.swift 文件:
//
// iGrow_GoalsApp.swift
// iGrow Goals
//
// Created by George Sepetadelis on 3/8/21.
//
import SwiftUI
import Firebase
import FirebaseAuth
import GoogleSignIn
import UserNotifications
@main
struct iGrow_GoalsApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene {
WindowGroup {
let viewModel = AppViewModel()
ContentView()
.environmentObject(viewModel)
}
}
}
extension iGrow_GoalsApp {
func setUpAthetication() {
FirebaseApp.configure()
}
}
class AppDelegate : NSObject, UIApplicationDelegate {
var window: UIWindow?
func application(
_ app: UIApplication,
open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]
) -> Bool {
var handled: Bool
handled = GIDSignIn.sharedInstance.handle(url)
if handled {
return true
}
// Handle other custom URL types.
// If not handled by this app, return false.
return false
}
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)
FirebaseApp.configure()
GIDSignIn.sharedInstance.clientID = FirebaseApp.app()?.options.clientID
return true
}
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
(UIApplication.shared.delegate as? AppDelegate)?.self.window = window
guard let _ = (scene as? UIWindowScene) else { return }
}
}
在使用此版本的 GoogleSignIn 之前,我遇到了同樣的問題
pod 'GoogleSignIn', '~> 4.4.0'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.