google/googlesignin-ios
[!IMPORTANT]
Installation
Google Sign-In is distributed with Swift Package Manager.
In Xcode, choose File > Add Package Dependencies…, enter https://github.com/google/GoogleSignIn-iOS, and add the product you need to your target:
GoogleSignIn— the core SDK (Swift and Objective-C).GoogleSignInSwift— the SwiftUIGoogleSignInButton.
Or add it to your Package.swift:
dependencies: [
.package(url: "https://github.com/google/GoogleSignIn-iOS", from: "10.0.0")
]and depend on .product(name: "GoogleSignIn", package: "GoogleSignIn-iOS") (and, for SwiftUI, .product(name: "GoogleSignInSwift", package: "GoogleSignIn-iOS")) in your target.
If you currently use CocoaPods, see Migrating from CocoaPods to Swift Package Manager.
Getting Started
Try either the Objective-C or Swift sample app. For example, to demo the Objective-C sample project:
git clone https://github.com/google/GoogleSignIn-iOS
open GoogleSignIn-iOS/Samples/ObjC/SignInSample/SignInSample.xcodeprojIf you would like to see a Swift example, take a look at Samples/Swift/DaysUntilBirthday.
- Add Google Sign-In to your own app by following our
- Take a look at the
Google Sign-In on macOS
Google Sign-In allows your users to sign-in to your native macOS app using their Google account and default browser. When building for macOS, the signInWithConfiguration: and addScopes: methods take a presentingWindow: parameter in place of presentingViewController:. Note that in order for your macOS app to store credentials via the Keychain on macOS, you will need to add $(AppIdentifierPrefix)$(CFBundleIdentifier) as the first item in its keychain access group.
Mac Catalyst
Google Sign-In also supports iOS apps that are built for macOS via Mac Catalyst. In order for your Mac Catalyst app to store credentials via the Keychain on macOS, you will need to add $(AppIdentifierPrefix)$(CFBundleIdentifier) as the first item in the keychain access group.
A Note on iOS Keychain Access Groups
GSI uses your default (first listed) keychain access group. If you don't add a custom keychain access group, the default keychain access group is provided by Xcode and looks like $(AppIdentifierPrefix)$(CFBundleIdentifier).
GSI removes keychain items upon fresh install to ensure that stale credentials from previous installs of your app are not mistakenly used. If your app uses a shared access group by default this may lead to new installs of apps sharing the same keychain access group to remove keychain credentials for apps already installed.
To prevent unintentional credential removal, you can explicitly list the typical default access group (or whatever you prefer so long as it is not shared) in your list first. GSI, will then use that default access group.
Package Metadata
Repository: google/googlesignin-ios
Default branch: main
README: README.md