Google SignIn without CocoaPods

4.7k views Asked by At

I am trying to integrate the GoogleSign-In for iOS with the documentation found here: https://developers.google.com/identity/sign-in/ios/start-integrating

How can I do this without using Cocoapods?

I've tried using the libraries and headers that Cocoapods download directly, but this led to many issues. Has anyone successfully converted a Cocoapod into a standalone library/framework?

4

There are 4 answers

1
class On BEST ANSWER

The standalone SDK is available here now: https://developers.google.com/identity/sign-in/ios/sdk/

As mentioned by other posters, you must add the following dependent frameworks:

  • AddressBook.framework
  • StoreKit.framework
  • SystemConfiguration.framework

You may also need to set Other Linker Flags: -ObjC flag in your project's build steps.

0
AudioBubble On

Also make sure you link the dependent frameworks.

  • AddressBook.framework
  • StoreKit.framework
  • SystemConfiguration.framework

See related Upgrading from Google Sign-In SDK 1.0.0 to 2.0.1 fails to compile on SKStore references.

0
Tomas On

They´ve updated the documentation:

https://developers.google.com/identity/sign-in/ios/start-integrating#swift-package-manager

Open your project in Xcode.

Add the Google Sign-In dependencies to your app (Xcode documentation):

Repository https://github.com/google/GoogleSignIn-iOS Version 6.0.2 Package product GoogleSignIn

If you are using SwiftUI, also add the following extension package product for the "Sign in with Google" button:

Package product GoogleSignInSwift

0
James Toomey On

After a week of grappling with this beast, I want to update this answer for version Google Sign-In SDK 4.0.0. The instructions at

https://developers.google.com/identity/sign-in/ios/sdk/

appear to be wrong for version 4.0.0. They say you only need to link

  • GoogleSignIn.framework
  • GoogleSignIn.bundle

(along with AddressBook.framework, StoreKit.framework, and SystemConfiguration.framework of course). However, you will get lots of mystifying

Undefined symbols for architecture x86_64

errors if that's all you include. The CHANGELOG.md file gets you closer to the truth with this statement:

For users of the stand-alone zip distribution, multiple frameworks are now provided and all need to be added to a project. This decomposition allows more flexibility in case of duplicated dependencies.

So in reality you also need to include:

  • GoogleAppUtilities.framework
  • GoogleAuthUtilities.framework
  • GoogleNetworkingUtilities.framework
  • GoogleSymbolUtilities.framework
  • GoogleUtilities.framework

So now you should be golden, right? As all good informercials say...

But wait, there's more!

You also need to include

  • libz.tbd

This answer gave the clue to including that library too. Without that, you will get the error

unrecognized selector sent to instance

but only on this line of code

GIDSignIn.sharedInstance().clientID = "MyClientID"

If you remark out that line, the code will work fine, even with this code still there

GIDSignIn.sharedInstance().delegate = self

To me this was the most misleading part. Most of the answers on the web for that error will say you need to set the OtherLinkerFlag to -ObjC, and I'm sure that's a common cause of problems if it's not set correctly or at all, but in my case it was clearly set right, plus the setting of the delegate worked, which meant that other properties of GIDSignIn could be set, so why not the clientID? I thought perhaps my clientID was wrong somehow and I wasted a lot of time chasing that false clue.

All of this headache can be avoided by just using the CocoaPod, but in my case I really wanted to make it work without adding the complexity that CocoaPods bring, because I'm also including Facebook's SDK.

P.S. I found this tutorial

http://www.appcoda.com/google-sign-in-how-to/

to be much better written than Google's tutorial, especially the reminder that you need to use a UIView and not a UIButton for the Google sign-in button. I spent some time confused about why I couldn't set the button's class to GIDSignInButton until I came across this tutorial. Just keep in mind that you'll need to link the libraries the way I described above rather than the way the tutorial says because it's different now.