Swiftpack.co - SKrotkih/swift-googlesignin as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by SKrotkih.
SKrotkih/swift-googlesignin 1.43.0
SwiftGoogleSignIn is an open-source package of using Google Sign-In for iOS and macOS
⭐️ 0
🕓 2 weeks ago
.package(url: "https://github.com/SKrotkih/swift-googlesignin.git", from: "1.43.0")

SwiftGoogleSignIn v1.43

SwiftGoogleSignIn is an open-source package which uses Google Sign-In for iOS and macOS and can be used to make sign in your app. Here you can find an example of using this package.


iOS 13, Swift 5.7

How to install it:

  • open your Xcode project for iOS
  • select File-Add packages...
  • in the Apple Swift Packages screen select Search or Enter Package URL
  • enter https://github.com/SKrotkih/swift-googlesignin.git
  • make sure SwiftGoogleSignIn is opened
  • press Add Package
  • Xcode creates 'Package Pependencies' group with SwiftGoogleSignIn package with last version
  • open your Xcode project settings - PROJECT section on the Package Dependencies tab
  • make sure the SwiftGoogleSignIn package name is presented there

How to use the package:

  • initialize stage:
   import SwiftGoogleSignIn

   // There are needed sensitive scopes for Google APIs to have ability to work properly
   // Make sure they are presented in your app. Then send request on verification
   let googleAPIscopes: [String]? = ["https://www.googleapis.com/auth/youtube",

   func application(_ application: UIApplication,
                    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
      SwiftGoogleSignIn.packageAPI.initialize(googleAPIscopes) // nil is a defaut value 
   func application(_ application: UIApplication,
                    open url: URL,
                    options: [UIApplication.OpenURLOptionsKey: Any] = [:]
   ) -> Bool {
       return SwiftGoogleSignIn.packageAPI.openUrl(url)
  • put 'Sign In' button:
   import SwiftGoogleSignIn

   struct SignInBodyView: View {

      var body: some View {
  • subscribe on the User sign in result action:
      .receive(on: RunLoop.main)
      .sink { in
         // $0 is a UserProfile data
      .store(in: &self.cancellableBag)
  • subscribe on the User sign in result action (if something went wrong):
      .sink(receiveCompletion: { completion in
         switch completion {
            case .failure(let error):
               // handle the error
         }, receiveValue: { theUserIsLoggedIn in
            if theUserIsLoggedIn {
               // the user signed in successfully
         .store(in: &cancellableBag)

Example of using the package.


  • 20-09-2022. Released 1.43.


Stars: 0
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics