firebase-ios-sdk: Bundle ID validation doesn't work in my share extension
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;
}
?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 19 (10 by maintainers)
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.
Thank you!
@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 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.