我正在尝试在我的应用程序中实现google登录。但问题是,当我将这行代码添加到我的App.swift文件中时,我会得到一个错误。我试图从()中删除sharedInstance,但是如果我这样做,就会得到另一个错误(Value of type 'GIDSignIn' has no member 'clientID')。我是斯威夫特和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 }
}
}发布于 2022-06-06 12:18:14
在使用这个版本的GoogleSignIn之前,我一直有同样的问题。
pod 'GoogleSignIn', '~> 4.4.0'https://stackoverflow.com/questions/69091345
复制相似问题