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

Bundle ID validation doesn't work in my share extension #5126

Closed
mdzwonek opened this issue Mar 17, 2020 · 19 comments · Fixed by #5531
Closed

Bundle ID validation doesn't work in my share extension #5126

mdzwonek opened this issue Mar 17, 2020 · 19 comments · Fixed by #5531
Assignees
Labels
api: core api: crashlytics extensions For iOS extensions targets (i.e. share, messages)
Milestone

Comments

@mdzwonek
Copy link

mdzwonek commented Mar 17, 2020

Step 0: Are you in the right place?

  • For issues or feature requests related to the code in this repository
    file a Github issue.
    • If this is a feature request please use the Feature Request template.
  • For general technical questions, post a question on StackOverflow
    with the firebase tag.
  • For general (non-iOS) Firebase discussion, use the firebase-talk
    google group.
  • For backend issues, console issues, and other non-SDK help that does not fall under one
    of the above categories, reach out to
    Firebase Support.
  • Once you've read this section and determined that your issue is appropriate for
    this repository, please delete this section.

[REQUIRED] Step 1: Describe your environment

  • Xcode version: Version 11.3.1 (11C504)
  • Firebase SDK version: [Firebase/Crashlytics] Version 4.0.0-beta.1
  • Firebase Component: Crashlytics
  • Component version: [Crashlytics] Version 3.14.0 (144)
  • Installation method: Zip file

[REQUIRED] Step 2: Describe the problem

Bundle ID validation doesn't work in my share extension.

Steps to reproduce:

What happened? How can we make the problem occur?
I'm getting the following error:

2020-03-17 14:28:11.021324+0000 ShareExtension[98130:23663525] 6.15.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.mycompany.myapp.ShareExtension'. Or you can download a new configuration file that matches your bundle identifier from https://console.firebase.google.com/ and replace the current one.
2020-03-17 14:28:11.025056+0000 ShareExtension[98130:23663330] [Firebase/Crashlytics] Version 4.0.0-beta.1
2020-03-17 14:28:11.036024+0000 ShareExtension[98130:23663330] [Crashlytics] Version 3.14.0 (144)
(lldb) po options.bundleID
com.mycompany.myapp.ShareExtension
(lldb) po [[NSBundle mainBundle] bundleIdentifier]
com.mycompany.myapp.ShareExtension

Bundle ID of the main app is com.mycompany.myapp, bundle ID of the extension is com.mycompany.myapp.ShareExtension. Calling [NSBundle mainBundle] returns com.mycompany.myapp.ShareExtension but it looks like the SDK is expecting it to return com.mycompany.myapp because the validation in +hasBundleIdentifierPrefix:inBundles: from FIRBundleUtil fails.

Relevant Code:

+ (BOOL)hasBundleIdentifierPrefix:(NSString *)bundleIdentifier inBundles:(NSArray *)bundles {
  for (NSBundle *bundle in bundles) {
    // This allows app extensions that have the app's bundle as their prefix to pass this test.
    NSString *applicationBundleIdentifier =
        [GULAppEnvironmentUtil isAppExtension]
            ? [self bundleIdentifierByRemovingLastPartFrom:bundle.bundleIdentifier]
            : bundle.bundleIdentifier;

    if ([applicationBundleIdentifier isEqualToString:bundleIdentifier]) {
      return YES;
    }
  }
  return NO;
}

Should it look more like this:

+ (BOOL)hasBundleIdentifierPrefix:(NSString *)bundleIdentifier inBundles:(NSArray *)bundles {
  for (NSBundle *bundle in bundles) {
    // This allows app extensions that have the app's bundle as their prefix to pass this test.
   if ([GULAppEnvironmentUtil isAppExtension]) {
      NSString *applicationBundleIdentifier = [self bundleIdentifierByRemovingLastPartFrom:bundle.bundleIdentifier];
      if ([applicationBundleIdentifier isEqualToString:bundleIdentifier]) {
        return YES;
      }
    }
    if ([bundle.bundleIdentifier isEqualToString:bundleIdentifier]) {
      return YES;
    }
  }
  return NO;
}

?

@morganchen12 morganchen12 added the extensions For iOS extensions targets (i.e. share, messages) label Mar 17, 2020
@paulb777
Copy link
Member

It's weird to see log from both the Firebase and Fabric Crashlytics. Are they both in the app?

2020-03-17 14:28:11.025056+0000 ShareExtension[98130:23663330] [Firebase/Crashlytics] Version 4.0.0-beta.1
2020-03-17 14:28:11.036024+0000 ShareExtension[98130:23663330] [Crashlytics] Version 3.14.0 (144)

@mdzwonek
Copy link
Author

Good point! Looks like I forgot to stop linking Fabric Crashlytics. Fixed it but I'm still getting a similar error:

2020-03-18 09:59:11.187958+0000 ShareExtension[58698:24283978] [Firebase/Crashlytics] Version 4.0.0-beta.1
2020-03-18 09:59:11.199347+0000 ShareExtension[58698:24284072] 6.15.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.mycompany.myapp.ShareExtension'. Or you can download a new configuration file that matches your bundle identifier from https://console.firebase.google.com/ and replace the current one.

@charlotteliang
Copy link
Contributor

Did you download the same GoogleService-Info.plist file from the main app to your share extension target?

@mdzwonek
Copy link
Author

Did you download the same GoogleService-Info.plist file from the main app to your share extension target?

Just double checked and I downloaded a separate Google config file for my share extension.

@ryanwilson
Copy link
Member

Ahh that's the issue then - the expectation is you're using the same app in the console and the same GoogleService-Info.plist - which would have the bundleID of the main app.

Can you try with that and see if it works for you? Also, if you had a particular reason to set up a separate app in the Firebase console for your extension it'd be helpful to know what kind of use-cases that folks need. Thanks!

(Good call @chliangGoogle)

@mdzwonek
Copy link
Author

Ohh, I didn't know that!

The reason for splitting the extension from the main app is that the #1 crash in the main app happens roughly 100x more often the #1 crash in the extension. And it's the same with active users, the main app has hundreds times more users than the extension.
If we combine all crashes in one dashboard then it's really hard to spot issues in the extension. Because I'm assuming that if we use the same config file in both the app and the extension then all of the crashes are going to show up in the same place, is that correct?

@ryanwilson
Copy link
Member

That's correct, yes. cc @TKBurner for any potential solutions from the Crashlytics side - what's the best way to filter crashes from extensions?

That's very helpful feedback and something we'll need to consider moving forward, thank you!

@ryanwilson
Copy link
Member

It looks like the original issue is still valid - we should be able to match exact bundleIDs for extensions in this sort of setup.

@charlotteliang
Copy link
Contributor

Part of reason we enforce the same config file is so that users can have unified identity as one app, e.g. you will only have to log in once with Auth. I also wonder if crashlytics support customized events so you can specify the difference there.

@mdzwonek
Copy link
Author

mdzwonek commented Apr 8, 2020

@chliangGoogle I don't fully understand the second part of your comment - is there a way to filter by the target in Firebase console? Ideally we'd like to be able to separate crashes in the main app from crashes in extensions because of a big difference in their volumes.

@morganchen12
Copy link
Contributor

@mdzwonek iirc the only way to do this currently is to set up separate projects for your extension and app. @samedson can better explain than I can.

@mdzwonek
Copy link
Author

@morganchen12 but this brings us back to this issue - we currently have it set up as a separate project but the SDK does not start correctly because it complains about an incorrect bundle ID.

@morganchen12
Copy link
Contributor

I see. I'm not sure if there's a clever way to make this workflow happen given the existing constraints of the console. I'll file a feature request for filtering by target in Crashlytics console, but it will be a while before the workflow you're describing is properly supported.

@mdzwonek
Copy link
Author

@morganchen12 thank you! 😊 Do you think it's also worth updating the code in the Firebase SDK in the way I suggested in the description of this issue to be able to use the SDK for extensions set up as separate projects?

@morganchen12
Copy link
Contributor

In principle we should make the adding an app extension workflow just work automatically. Changing the bundle ID validation may not be the best way to do that, but if it is, then yes.

There's a lot of complexity in supporting non-iOS Apple platforms because Firebase has historically been very tightly coupled to iOS and there's a substantial cost to undoing that. We've paid part of that cost in the community-supported macOS/tvOS distributions, but we still have a ways to go.

@mdzwonek
Copy link
Author

It all does make sense to me. But I'm just a user of the library, I'm not aware of all the constraints and I have no idea what's the best way of addressing the problem.
I do feel like bundle IDs and app extensions are already coupled with the iOS platform so maybe this could be the way to go?

@mdzwonek
Copy link
Author

mdzwonek commented May 5, 2020

Any updates on this?

@maksymmalyhin
Copy link
Contributor

@mdzwonek Thank you for your detailed explanation of the issue and a fix suggestion. We decided to apply the fix suggested by you. Appreciate your contribution.

@mdzwonek
Copy link
Author

mdzwonek commented May 5, 2020

Thank you!

@maksymmalyhin maksymmalyhin added this to the 6.25.0 - M71 milestone May 5, 2020
@firebase firebase locked and limited conversation to collaborators Jun 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: core api: crashlytics extensions For iOS extensions targets (i.e. share, messages)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants