Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions FirebaseCore/Sources/FIRApp.m
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ @implementation FIRApp
+ (void)configure {
FIROptions *options = [FIROptions defaultOptions];
if (!options) {
#if DEBUG
[self findMisnamedGoogleServiceInfoPlist];
#endif // DEBUG
[NSException raise:kFirebaseCoreErrorDomain
format:@"`FirebaseApp.configure()` could not find "
@"a valid GoogleService-Info.plist in your project. Please download one "
Expand Down Expand Up @@ -883,4 +886,33 @@ - (void)appDidBecomeActive:(NSNotification *)notification {
}
}

#if DEBUG
+ (void)findMisnamedGoogleServiceInfoPlist {
for (NSBundle *bundle in [NSBundle allBundles]) {
// Not recursive, but we're looking for misnames, not people accidentally
// hiding their config file in a subdirectory of their bundle.
// This is only really designed for iOS.
NSArray *plistPaths = [bundle pathsForResourcesOfType:@"plist" inDirectory:nil];
for (NSString *path in plistPaths) {
@autoreleasepool {
NSDictionary<NSString *, id> *contents = [NSDictionary dictionaryWithContentsOfFile:path];
if (contents == nil) {
continue;
}

NSString *projectID = contents[@"PROJECT_ID"];
if (projectID != nil) {
[NSException raise:kFirebaseCoreErrorDomain
format:@"`FirebaseApp.configure()` could not find the default "
@"configuration plist in your project, but did find one at "
@"%@. Please rename this file to GoogleService-Info.plist to "
@"use it as the default configuration.",
path];
}
}
}
}
}
#endif // DEBUG

@end