简体   繁体   中英

Cannot call value of non-function type 'GIDSignIn'

I'm trying to implement google sign in into my app. But the problem is when i add this line of code to my App.swift file i'm getting an error. I tried to remove the () from the sharedInstance but if i do this i'm getting another error ( Value of type 'GIDSignIn' has no member 'clientID' ). I'm beginner on swift and swiftUI

The error:

Cannot call value of non-function type 'GIDSignIn'

Line of code:

GIDSignIn.sharedInstance.clientID = FirebaseApp.app()?.options.clientID

My App.swift File:

//
//  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'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM