Skip to content

Support SPM #886

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

Closed
nikitaame opened this issue Jul 29, 2020 · 50 comments
Closed

Support SPM #886

nikitaame opened this issue Jul 29, 2020 · 50 comments
Assignees

Comments

@nikitaame
Copy link

From this thread, firebase/firebase-ios-sdk#3136, Firebase is going to be supporting SPM in the coming near future. Would your team consider doing so as well?

Thanks!

@paulb777
Copy link
Member

I've done some prototyping in https://github.com/firebase/FirebaseUI-iOS/tree/pb-spm. Since SPM does not have a concept of subspecs, there will need to be a strategy about how to map those to SPM and what the implications will be to imports.

@borut-t
Copy link

borut-t commented Sep 30, 2020

@paulb777 any estimate on SPM support since firebase SDK already offers one?
Since UISDK has a dependency on firebaseSDK, we cannot use SPM anywhere atm.

@speedyacme
Copy link

Hello, Any update on this?
Thanks

@ramunasjurgilas
Copy link

I did try to install pb-spm branch and it failed with an error:
image

@micheau-bastien
Copy link

micheau-bastien commented Jan 1, 2021

Hello!
Anyone managed to install FirebaseUI with SPM yet?

@mattkwan
Copy link

mattkwan commented Feb 2, 2021

I've managed to install FirebaseUI SPM using the pb-spm branch. I needed to do a clean build, and replace imports of Firebase/FirebaseUI with imports of FirebaseStorage, FirebaseFunctions, AuthUI, EmailUI, etc, but it builds OK.

However, when I run the code below it fails with

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle <...> (loaded)' with name 'FUIAuthPickerViewController''

I'm guessing FUIAuthPickerViewController.nib isn't appearing in the resource dependencies. Is there a workaround or fix for this?

import SwiftUI
import AuthUI
import EmailUI

struct LoginView: UIViewControllerRepresentable {
  func makeUIViewController(context: Context) -> UIViewController {
    let authUI = FUIAuth.defaultAuthUI()
    authUI?.providers = [FUIEmailAuth()]
    return authUI!.authViewController()
  }
  
  func updateUIViewController(
    _ uiViewController: UIViewController,
    context: UIViewControllerRepresentableContext<LoginView>
  ) {
  }
}

@mattkwan
Copy link

mattkwan commented Feb 3, 2021

I fixed the initial NIB error by explicitly specifying the FirebaseUI bundles in the delegate, but then it crashes trying to load the FUIAuthTableViewCell NIB, and I can't find a way to specify the bundle for that class. In any case, the strings in the UI are wrong ("AuthPickerTitle", "SignInWithEmail") and the email icon is missing. So I'm still looking for a way forward.

class AuthDelegate: NSObject, FUIAuthDelegate {
  private var authBundle: Bundle?
  private var emailBundle: Bundle?

  override init() {
    super.init()
    if let bundleURL = Bundle.main.url(
        forResource: "FirebaseUI_AuthUI",
        withExtension: "bundle") {
      authBundle = Bundle(url: bundleURL)
    }
    if let bundleURL = Bundle.main.url(
        forResource: "FirebaseUI_EmailUI",
        withExtension: "bundle") {
      emailBundle = Bundle(url: bundleURL)
    }
  }

  func authPickerViewController(
    forAuthUI authUI: FUIAuth
  ) -> FUIAuthPickerViewController {
    return FUIAuthPickerViewController(
      nibName: "FUIAuthPickerViewController",
      bundle: authBundle,
      authUI: authUI)
  }
    
  func emailEntryViewController(
    forAuthUI authUI: FUIAuth
  ) -> FUIEmailEntryViewController {
    return FUIEmailEntryViewController(
      nibName: "FUIEmailEntryViewController",
      bundle: emailBundle,
      authUI: authUI)
  }
}

@nikitaame
Copy link
Author

nikitaame commented Feb 4, 2021

@paulb777 Any update on when this might move from prototype to main? Would love to get some of the latest updates and fixes that have been pushed out! Would also love to be able to use this for other things besides AuthUI!

Edit: Not only would I appreciate being able to use SPM, but SPM is also the only way I can do dependency management now. A lot of problems with Cocoapods on M1 Macbooks (even running on Rosetta). This would mean the world and allow me to once again use this wonderful library!

@SebastianBO
Copy link

Nice to see I'm not the only one waiting for this..

@morganchen12
Copy link
Contributor

Hey all, additional progress has been made on the pb-spm branch. Please test out the new changes and let me know if you run into any issues.

@nikitaame
Copy link
Author

@morganchen12 thank you for making those updates! So close now, seeing a similar but different issue to what @mattkwan was seeing.

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not find country code file'
Guessing something is wrong with linking within PhoneAuthUI

Whatever you did to fix Matt's issue worked because I was previously seeing that issue as well when commenting out a bunch of code that was using the previously unsupported modules. Do you think you could apply the same fix from FUIAuthPickerViewController.nib onto the country code file?

@nikitaame
Copy link
Author

@morganchen12 scratch that. I actually tried to start an AuthVC up without phone auth in the list of providers and got the same error as Matt:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle <> (loaded)' with name 'FUIAuthPickerViewController''

@morganchen12
Copy link
Contributor

@nikitaame the missing bundle resources should be fixed now.

@nikitaame
Copy link
Author

@morganchen12 everything looks good and is running smoothly minus one small bug. Think some localization file might still not be linked? Seeing a TermsOfServiceMessage key instead of an actual string.

Screen Shot 2021-02-11 at 5 00 10 PM

Otherwise, thank you for your amazing work! I am finally able to once again work with Firebase + FirebaseUI thanks to you! Will this be out in the next release?

@morganchen12 morganchen12 self-assigned this Feb 13, 2021
@SebastianBO
Copy link

Got it to work too! Thank you! - Can approve that there seems to be something wrong with Localization.
Screenshot 2021-02-22 at 17 14 43

@SebastianBO
Copy link

Screenshot 2021-02-22 at 17 23 15

Also maybe wrong forum but how do we achieve FacebookAuth/GoogleAuth/AppleAuth with this library?

Screenshot 2021-02-22 at 17 29 11

@morganchen12
Copy link
Contributor

Facebook Auth and Google Auth both have library dependencies that do not support SwiftPM (Facebook supports SwiftPM only for its Swift SDKs, but we depend on their ObjC SDKs since FirebaseUI is an ObjC project). Unfortunately, we're blocked on those libraries.

I'll take a look at the localization files bug soon.

@ianphaas
Copy link

Any update on the localization bug? This still seems to be an issue.

@morganchen12
Copy link
Contributor

The localization resources bug should now be fixed.

@gallaugher
Copy link

So sorry - I'm missing something basic on understanding which URL to use to test this. I've tried:
https://github.com/firebase/FirebaseUI-iOS/compare/pb-spm
and
https://github.com/firebase/FirebaseUI-iOS/tree/pb-spm
but I get an error:
"The remote repository could not be accessed: Make sure a valid repository exists at the specified location and that the correct credentials have been supplied."
I'm sure I'm just missing something newbie-ish. Thanks for tolerating the question & correcting what I'm missing.

@morganchen12
Copy link
Contributor

See Paul's comment in your other issue: firebase/firebase-ios-sdk#7824 (comment)

@ianphaas
Copy link

Before the most recent update, FirebaseUI was working fine, however when I tried to update to the latest version to get the localization fixes, I got this error.
Screen Shot 2021-04-10 at 9 11 16 AM

@nikitaame
Copy link
Author

@thecodeguyexamples seems to be working fine for me. Did you try the usual reset of SPM cache, clean derived data, etc dance?

Thanks for fixing this @morganchen12!

@tidbeck
Copy link
Contributor

tidbeck commented Apr 12, 2021

Facebook Auth and Google Auth both have library dependencies that do not support SwiftPM (Facebook supports SwiftPM only for its Swift SDKs, but we depend on their ObjC SDKs since FirebaseUI is an ObjC project). Unfortunately, we're blocked on those libraries.

I'll take a look at the localization files bug soon.

@morganchen12 do you expect Facebook Auth and Google Auth to support SwiftPM in the future?

@morganchen12
Copy link
Contributor

morganchen12 commented Apr 12, 2021

Facebook Auth already supports SPM, though only for their Swift module, which we cannot use since FirebaseUI is an ObjC project. It's unclear if they'll add SPM support for their ObjC libraries as well. If ObjC usage of the Facebook Auth FirebaseUI module is low, we could rewrite it in Swift easily since it's very small.

Google Auth will add SPM support in the future.

@morganchen12
Copy link
Contributor

SPM support has now landed in master, and will be released after the Firebase 8 major version update.

@gallaugher
Copy link

gallaugher commented Apr 27, 2021 via email

@SchwartzLizer
Copy link

CleanShot 2021-04-30 at 17 52 24@2x

i have problem when i using SPM and i oull branch pb-spm anyone have this problem?

@ghost
Copy link

ghost commented May 2, 2021

Hi all,

thanks for the effort! I also get the following errors using the pb-spm or master branch.

"Could not build Objective-C module 'FirebaseAuthUI'"

Screenshot 2021-05-02 at 20 29 00

@nipapadak
Copy link

@Tixamaster It worked for me when I made the following change: nipapadak@11db727

@ghost
Copy link

ghost commented May 2, 2021

@nipapadak Thanks a lot that solved this problem!

Now I get the following (did the FUI names also change?):

Screenshot 2021-05-02 at 20 54 37

In addition I still get this compiler error:
Screenshot 2021-05-02 at 21 00 09

@morganchen12
Copy link
Contributor

@Tixamaster the module names changed, so now you need to import each auth provider module separately.

import FirebaseEmailAuthUI
// ...

@ghost
Copy link

ghost commented May 3, 2021

@Tixamaster the module names changed, so now you need to import each auth provider module separately.

import FirebaseEmailAuthUI
// ...

Thanks! But I still get the compiler error shown above :/

@morganchen12
Copy link
Contributor

Header import errors should be fixed in bb544f8.

@tidbeck
Copy link
Contributor

tidbeck commented May 4, 2021

Facebook Auth already supports SPM, though only for their Swift module, which we cannot use since FirebaseUI is an ObjC project. It's unclear if they'll add SPM support for their ObjC libraries as well. If ObjC usage of the Facebook Auth FirebaseUI module is low, we could rewrite it in Swift easily since it's very small.

Google Auth will add SPM support in the future.

On the facebook-ios-sdk README under Swift Package Manager it says:

If you explicitly DO NOT want to include Swift, import FBSDKCoreKit FBSDKLoginKit and FBSDKShareKit

Doesn't that mean that they have SPM support for ObjC libraries?

@ianphaas
Copy link

ianphaas commented May 4, 2021 via email

@morganchen12
Copy link
Contributor

@thecodeguyexamples can you share the path in the error?

@ianphaas
Copy link

ianphaas commented May 4, 2021 via email

@morganchen12
Copy link
Contributor

@thecodeguyexamples Thanks, should be fixed in 4201323.

@ianphaas
Copy link

ianphaas commented May 5, 2021

Alright, I will test this out when I get the chance.

@ghost
Copy link

ghost commented May 12, 2021

Thy it works now. But I don't get access to the name of the user when using Apple Sign In.
Is this a general issue or only with the new SPM packaging?

@morganchen12
Copy link
Contributor

@Tixamaster that's a regression unrelated to SPM.

@ghost
Copy link

ghost commented May 12, 2021

Okay thanks. Can you maybe push me to a hint where I can get the name? As I could only find a closed issue with the info that it should have been implemented.

@morganchen12
Copy link
Contributor

@Tixamaster please file a separate issue.

@gallaugher
Copy link

I see Paul's comment that the branch is pb-spm, but when I try the following, Xcode can't seem to resolve FirebaseUI-iOS.git if I select "branch" and add "pb-spm". See error, below. I've already installed Firebase 8.0 using SPM in this project.
So sorry if I'm missing something basic, but how do I install this branch using Swift Package Manager. Thanks!
spm-not-working
spm-not-working-2

@morganchen12
Copy link
Contributor

Hey @gallaugher, you should be using the master branch now. Note that FirebaseUI has not yet been updated for Firebase 8 support. I'll do that soon.

@gallaugher
Copy link

Just tried rolling back Firebase to 7.9 and installing with SPM, then tried AuthUI and got this error:
AuthUI problem

@ianphaas
Copy link

ianphaas commented May 15, 2021 via email

@morganchen12
Copy link
Contributor

morganchen12 commented May 25, 2021

SPM support on master is now updated for Firebase 8. Please clear your package caches and try reinstalling.

Also added Facebook login support.

@morganchen12
Copy link
Contributor

This has now been released.

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

No branches or pull requests