ios - 无法调用非函数类型“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 }
}
}
解决方案
推荐阅读
- angular - 从组件内更新属性绑定
- powerapps - Powerapps 过滤器公式中的 2 个条件
- grafana - Grafana 转换:在表格面板中计算百分比
- azure-functions - 你如何让 func start 为 azure 函数输出 versbose 日志
- sql - 使用正则表达式数据拆分的查询没有得到正确的结果oracle SQL
- isabelle - 如何在 Isabelle/HOL 中使用 lambda 表达式?
- visual-studio-code - 在 VSCode 中编辑 Emmet 缩写
- kubernetes - 连接到 Kubernetes 服务导致连接被拒绝
- prolog - 是否可以在序言中证明嵌套规则?
- python - 用f2py编译后获取模块没有属性错误