Cannot find type GIDSignInDelegate and property clientID with Google sign in with firebase
Since 6.0.0
GoogleSignIn doesn't have a delegate anymore, they've switched to completions(probably to easily support new swift concurrency).
Check out migration guide.
You can use it like this now, in your view controller:
GIDSignIn.sharedInstance.signIn(
with: "clientId",
presenting: self // your view controller
) { user, error in
if let token = user?.authentication.idToken {
completionHandler(token, nil)
return
}
guard let error = error as? GIDSignInError else {
fatalError("No token and no GIDSignInError: \(String(describing: error))")
}
completionHandler(nil, error)
}
In your AppDelegate
you need this(just like before):
func application(
_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey: Any] = [:]
) -> Bool {
return GIDSignIn.sharedInstance.handle(openURL)
}
Type ViewController does not conform to protocol GIDSignInDelegate
Add These function to your code :-
func signIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!, withError error: NSError!) {...}
func signIn(signIn: GIDSignIn!, didDisconnectWithUser user: GIDGoogleUser!, withError error: NSError!) {...}
For future reference , if you ever see this error just cmd+click the delegate
in your case GIDSignInDelegate protocol that your class is not conforming to and you will see a bunch of function written in that protocol that needs to be conformed by this class - which is to inherit from that protocol
, include those function in your class and you are golden..(Mostly)
PS:- some protocol functions are marked optional meaning including them is up to you and you wont face this error if you dont, but some which are not are mandatory.
Segue after Firebase Google LogIn Xcode 11
Like this:
let storyboard = UIStoryboard(name: "Main", bundle: Bundle.main)
var vc: UIViewController?
vc = storyboard.instantiateViewController(withIdentifier: "signed")
window?.rootViewController = vc
window?.makeKeyAndVisible()
AppDelegate does not conform to protocol 'GIDSignInDelegate' in Swift 3
It looks like you defined the methods of that protocol outside of the AppDelegate
class, so they are just global functions, not methods.
You need to move them inside the }
that closes AppDelegate
(just above the first protocol method).
Tip: if you select all of the code in that file and press
Ctrl+I
Xcode will reindent your code which may make it easier to see what's going wrong.
Firebase iOS Google sign in -- use of undeclared type GIDSignInDelegate
From your code, its vivid that you're currently running Swift 3.0 but some of your methods are still Swift 2. For Swift 3.0, the new delegate method is
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!)
{
if error != nil
{
print("Google Sign In Error")
}
else
{
// Do stuff
}
}
openURL
, didFinishLaunchingWithOptions
and didDisconnectWithUser
also have changed in Swift 3.0. I'd recommend you re-implement them.
Related Topics
How to Restrict an Enum to Certain Cases of Another Enum
Core Image Filter Cisourceovercompositing Not Appearing as Expected with Alpha Overlay
How to Split a String into a [String] and Not [Substring]
Unwrapping Optional in Swiftui View
Swift Any Difference Between Closures and First-Class Functions
"Raw Value for Enum Case Is Not Unique" for Swift Enum with Float Raw Values
How to Convert 4 Bytes to a Swift Float
Explit Conformance to Codable Removes Memberwise Initializer Generation on Structs
No More 'Private Init' in Swift
Repeating Action Continuously in Swiftui
Constant 'Result' Inferred to Have Type (), Which May Be Unexpected