Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swift Package Manager Support? #1004

Closed
gallaugher opened this issue Oct 1, 2021 · 5 comments
Closed

Swift Package Manager Support? #1004

gallaugher opened this issue Oct 1, 2021 · 5 comments

Comments

@gallaugher
Copy link

Welcome to FirebaseUI and thanks for submitting an issue!

Please take a look at open issues, as well as resolved issues, to see if your issue is either already being addressed, or has been solved by someone else.

If your issue concerns the CocoaPods error, "...transitive dependencies that include static binaries", please take a look at any of the following issues and see if your problem is solved: #48, #47, #46, #34, #23.

If not, please feel free to fill in the following info so we can help faster!

Step 1: Are you in the right place?

  • For issues or feature requests related to the code in this repository file a GitHub issue.
  • For general technical questions, post a question on StackOverflow tagged appropriately.
  • For general Firebase discussion, use the firebase-talk google group
  • For help troubleshooting your application that does not fall under one of the above categories, reach out to the personalized Firebase support channel

Step 2: Describe your environment

  • Objective C or Swift: Swift
  • iOS version: 13
  • Firebase SDK version: 7.11.1
  • FirebaseUI version: ?
  • CocoaPods Version: n/a

Step 3: Describe the problem:

Installed Firebase using Swift Package Manager. It seems FirebaseUI is not supported yet.
import FirebaseUI results in the following build error:
No such module 'FirebaseUI'

Steps to reproduce:

  1. Install Firebase using Swift Packager Manager, including FirebaseAuth
  2. Try adding FirebaseUI with import FirebaseUI, with all steps followed that would happen except for cocoapod install
  3. error above occurs

Observed Results:

  • What happened? This could be a description, log output, etc.
    No such module 'FirebaseUI'
    at line:
    import FirebaseUI

Expected Results:

  • What did you expect to happen?

The app to successfully build & run

Relevant Code:

//
//  LoginViewController.swift
//  Demo-SMP-Firebase-Authentication
//
//  Created by gallaugh on 10/1/21.
//

import UIKit
import FirebaseUI

class LoginViewController: UIViewController {
  
  var authUI: FUIAuth!

  override func viewDidLoad() {
      super.viewDidLoad()
      
      authUI = FUIAuth.defaultAuthUI()
      // You need to adopt a FUIAuthDelegate protocol to receive callback
      authUI.delegate = self
  }
  
  override func viewDidAppear(_ animated: Bool) {
      super.viewDidAppear(animated)
      signIn()
  }

  func signIn() {
      let providers: [FUIAuthProvider] = [
        FUIGoogleAuth(),
      ]
      if authUI.auth?.currentUser == nil { // user has not signed in
          self.authUI.providers = providers // show providers named after let providers: above
          let loginViewController = authUI.authViewController()
          loginViewController.modalPresentationStyle = .fullScreen
          present(loginViewController, animated: true, completion: nil)
      } else { // user is already logged in
          performSegue(withIdentifier: "FirstShowSegue", sender: nil)
      }
  }
  
  func signOut() {
      do {
          try authUI!.signOut()
      } catch {
          print("😡 ERROR: couldn't sign out")
          performSegue(withIdentifier: "FirstShowSegue", sender: nil)
      }
  }
  
  @IBAction func unwindSignOutPressed(segue: UIStoryboardSegue) {
      if segue.identifier == "SignOutUnwind" {
          signOut()
      }
  }
}

extension LoginViewController: FUIAuthDelegate {
  func authPickerViewController(forAuthUI authUI: FUIAuth) -> FUIAuthPickerViewController {
      let marginInsets: CGFloat = 16.0 // amount to indent UIImageView on each side
      let topSafeArea = self.view.safeAreaInsets.top
      
      // Create an instance of the FirebaseAuth login view controller
      let loginViewController = FUIAuthPickerViewController(authUI: authUI)
      
      // Set background color to white
      loginViewController.view.backgroundColor = UIColor.white
      loginViewController.view.subviews[0].backgroundColor = UIColor.clear
      loginViewController.view.subviews[0].subviews[0].backgroundColor = UIColor.clear
      
      // Create a frame for a UIImageView to hold our logo
      let x = marginInsets
      let y = marginInsets + topSafeArea
      let width = self.view.frame.width - (marginInsets * 2)
      //        let height = loginViewController.view.subviews[0].frame.height - (topSafeArea) - (marginInsets * 2)
      let height = UIScreen.main.bounds.height - (topSafeArea) - (marginInsets * 2)
      
      let logoFrame = CGRect(x: x, y: y, width: width, height: height)
      
      // Create the UIImageView using the frame created above & add the "logo" image
      let logoImageView = UIImageView(frame: logoFrame)
      logoImageView.image = UIImage(named: "logo")
      logoImageView.contentMode = .scaleAspectFit // Set imageView to Aspect Fit
      loginViewController.view.addSubview(logoImageView) // Add ImageView to the login controller's main view
      return loginViewController
  }
}


@morganchen12
Copy link
Contributor

The module names changed in the last major release. You'll have to import FirebaseAuthUI instead of FirebaseUI now.

@gallaugher
Copy link
Author

The documentation needs to be changed online:
https://firebase.google.com/docs/auth/ios/firebaseui
It still refers to FirebaseUI, not FirebaseAuthUI.
Does FirebaseAuthUi cover GoogleAuthUI, or does one also need FirebaseGoogleAuthUI when using Google, or does FirebaseAuthUI cover this?

@morganchen12
Copy link
Contributor

Thanks @gallaugher, I'll update those docs. You'll need FirebaseGoogleAuthUI when using Google.

@morganchen12 morganchen12 reopened this Oct 1, 2021
@morganchen12
Copy link
Contributor

The documentation has ben updated.

@NewestUser
Copy link

NewestUser commented Aug 27, 2022

After adding https://github.com/firebase/firebase-ios-sdk in SwiftPackageManager I chose FirebaseAuth as a package that I want to add to my project.
Then import FirebaseAuthUI still resulted in No such module 'FirebaseAuthUI'.
Am I missing something?

UPDATE:
Just realised I was importing the wrong repo.
Instead I should add https://github.com/firebase/FirebaseUI-iOS. It would be nice to add that in the README though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants