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

iOS Extensions Support #797

Open
mhdhejazi opened this issue Sep 30, 2019 · 12 comments
Open

iOS Extensions Support #797

mhdhejazi opened this issue Sep 30, 2019 · 12 comments
Assignees

Comments

@mhdhejazi
Copy link

I'm trying to add Firebase to an iMessage app extension.
I created a project in Firebase and added two iOS apps, one for the main app (id: com.company.app), and the other for the extension (id: com.company.app.stickers).
I followed the guides and added the proper GoogleService-Info.plist file to each target.
But when I run the extension I see error this in Xcode output:

6.9.0 - [Firebase/Core][I-COR000008] The project's Bundle ID is inconsistent with either the Bundle ID in 'GoogleService-Info.plist', or the Bundle ID in the options if you are using a customized options. To ensure that everything can be configured correctly, you may need to make the Bundle IDs consistent. To continue with this plist file, you may change your app's bundle identifier to 'com.company.app.stickers'. Or you can download a new configuration file that matches your bundle identifier from https://console.firebase.google.com/ and replace the current one.

I made sure the bundle identifier of the extension is actually com.company.app.stickers. But the interesting thing is that when I tried to use the main GoogleService-Info.plist for the extension target the error disappeared although the bundle id in this plist file is com.company.app and the bundle id of the extension target is different!

So, am I doing anything wrong here? Or iOS extensions are not supported?

@morganchen12
Copy link
Contributor

Extensions are not officially supported, but some Firebase SDKs do work in extensions. In this case it's fine to use the main GoogleService-Info.plist file in the extension.

@mhdhejazi
Copy link
Author

Does the error make sense though?
I mean what's the cause of the bundle id inconsistency here? And why does it accept the main GoogleService-Info.plist that contains the main app id?
Does Firebase check the current bundle id or the root bundle's one?
I think this is a bit confusing and deserves a note in the documentation.

@morganchen12 morganchen12 reopened this Sep 30, 2019
@morganchen12 morganchen12 self-assigned this Sep 30, 2019
@mhdhejazi
Copy link
Author

mhdhejazi commented Sep 30, 2019

P.S. I needed to create a different app in my Firebase project with the bundle id of the extension for Crashlytics to work. This makes things more confusing now. Crashlytics needs a different app in Firebase but I should not use its GoogleService-Info.plist?

@morganchen12
Copy link
Contributor

Hm, that's definitely not good. Some background: The first warning message you got was from Analytics, which will discard some early lifecycle logs if the GoogleService-Info.plist has a mismatched bundle ID but otherwise work fine. Crashlytics is more restrictive, since it uses the bundle id to uniquely identify your binary. Since your extension is a separate process from your main app, you'll most likely need to use a separate GoogleService-Info.plist and just ignore the Analytics warning log.

We'll look into ways to make this experience better.

@inPhilly
Copy link

inPhilly commented Jan 4, 2020

This error is still happening. It's confusing to the user and it should be resolved. Many apps use app extensions and need crash reporting for them.

@inPhilly
Copy link

inPhilly commented Jan 4, 2020

Also, I can't verify my app extension because of this issue. Everything is setup correctly (two apps in same project, two files, each with their respective target), but this error is stopping the verification.

@inPhilly
Copy link

We'll look into ways to make this experience better.

Any progress on this front?

@morganchen12
Copy link
Contributor

No. This is a lower priority for us than macOS native and Catalyst support.

@jeffreyrobert
Copy link

@morganchen12 thanks for the update! Is there anywhere for us to know which Firebase SDKs will work and which won't?

For example, after a bit of work I have Analytics working (minus a few issues), but I don't have Crashlytics working. Would be great to know if this can work in iMessage Extensions or not before I pour the time in.

Thanks in advance!

@morganchen12
Copy link
Contributor

We don't have a matrix of which platforms are supported by which Firebase components. Crashlytics will probably work if you can set up the extension as a separate app and convince Crashlytics it's just reporting another app's crashes.

With this year's WWDC adding even more emphasis on non-app targets in the Apple ecosystem, we've increased the pressure internally to provide first-class support for non-app Apple platforms targets, but I don't have any concrete news or timelines to share.

@tehsven
Copy link

tehsven commented Aug 4, 2020

@jeffreyrobert do you mind sharing how you were able to get Analytics working for your extension? I set up my app with two Info plist files like the original post, but no analytics were being reported.

@jeffreyrobert
Copy link

@tehsven sorry for the delay. Hope you were able to get it working, if not (and for others). This is my current setup.

It seems that the Firebase team has made a lot of improvements this year (2020) in regards to Extension support for their SDKs. I updated to the latest SDKs and everything worked pretty smoothly for me. Here's my setup:

Bundle ID
I believe the recommended setup is to use your Main App Target's bundle ID for your Firebase app. So do not include the .MessagesExtension.
I set my app up before this was possible, so my Firebase app is using my iMessage Extension Target's bundle ID including .MessagesExtension. This may give me issues down the line but I don't actually have a Main App, my app is a standalone iMessage Extension.

Initialization

    override func willBecomeActive(with conversation: MSConversation) {

        // need to do this check to handle instances of application running in transcript view
        // note this check will cause this log:
        // [Firebase/Core][I-COR000005] No app has been configured yet.
        
        if let firebaseApps = FirebaseApp.allApps,
            !firebaseApps.isEmpty {
            
            // already configured
            
        } else {
            FirebaseApp.configure()
        }

Versions

  • Firebase/Core (6.32.2):
    • Firebase/CoreOnly
    • FirebaseAnalytics (= 6.8.2)
  • Firebase/CoreOnly (6.32.2):
    • FirebaseCore (= 6.10.2)
  • Firebase/Crashlytics (6.32.2):
    • Firebase/CoreOnly
    • FirebaseCrashlytics (~> 4.6.0)
  • Firebase/RemoteConfig (6.32.2):
    • Firebase/CoreOnly
    • FirebaseRemoteConfig (~> 4.9.0)
  • FirebaseABTesting (4.2.0):
    • FirebaseCore (~> 6.10)
  • FirebaseAnalytics (6.8.2):
    • FirebaseCore (~> 6.10)
    • FirebaseInstallations (~> 1.6)
    • GoogleAppMeasurement (= 6.8.2)
    • GoogleUtilities/AppDelegateSwizzler (~> 6.7)
    • GoogleUtilities/MethodSwizzler (~> 6.7)
    • GoogleUtilities/Network (~> 6.7)
    • "GoogleUtilities/NSData+zlib (~> 6.7)"
    • nanopb (~> 1.30906.0)
  • FirebaseCore (6.10.2):
    • FirebaseCoreDiagnostics (~> 1.6)
    • GoogleUtilities/Environment (~> 6.7)
    • GoogleUtilities/Logger (~> 6.7)
  • FirebaseCoreDiagnostics (1.6.0):
    • GoogleDataTransport (~> 7.2)
    • GoogleUtilities/Environment (~> 6.7)
    • GoogleUtilities/Logger (~> 6.7)
    • nanopb (~> 1.30906.0)
  • FirebaseCrashlytics (4.6.0):
    • FirebaseCore (~> 6.10)
    • FirebaseInstallations (~> 1.6)
    • GoogleDataTransport (~> 7.2)
    • nanopb (~> 1.30906.0)
    • PromisesObjC (~> 1.2)
  • FirebaseInstallations (1.7.0):
    • FirebaseCore (~> 6.10)
    • GoogleUtilities/Environment (~> 6.7)
    • GoogleUtilities/UserDefaults (~> 6.7)
    • PromisesObjC (~> 1.2)
  • FirebaseRemoteConfig (4.9.0):
    • FirebaseABTesting (~> 4.2)
    • FirebaseCore (~> 6.10)
    • FirebaseInstallations (~> 1.6)
    • GoogleUtilities/Environment (~> 6.7)
    • "GoogleUtilities/NSData+zlib (~> 6.7)"

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

5 participants