@@ -112,6 +112,9 @@ @implementation FIRApp
112
112
+ (void )configure {
113
113
FIROptions *options = [FIROptions defaultOptions ];
114
114
if (!options) {
115
+ #if DEBUG
116
+ [self findMisnamedGoogleServiceInfoPlist ];
117
+ #endif // DEBUG
115
118
[NSException raise: kFirebaseCoreErrorDomain
116
119
format: @" `FirebaseApp.configure()` could not find "
117
120
@" a valid GoogleService-Info.plist in your project. Please download one "
@@ -883,4 +886,32 @@ - (void)appDidBecomeActive:(NSNotification *)notification {
883
886
}
884
887
}
885
888
889
+ #if DEBUG
890
+ + (void )findMisnamedGoogleServiceInfoPlist {
891
+ for (NSBundle *bundle in [NSBundle allBundles ]) {
892
+ // Not recursive, but we're looking for misnames, not people accidentally
893
+ // hiding their config file in a subdirectory of their bundle.
894
+ NSArray *plistPaths = [bundle pathsForResourcesOfType: @" plist" inDirectory: nil ];
895
+ for (NSString *path in plistPaths) {
896
+ @autoreleasepool {
897
+ NSDictionary <NSString *, id > *contents = [NSDictionary dictionaryWithContentsOfFile: path];
898
+ if (contents == nil ) {
899
+ continue ;
900
+ }
901
+
902
+ NSString *projectID = contents[@" PROJECT_ID" ];
903
+ if (projectID != nil ) {
904
+ [NSException raise: kFirebaseCoreErrorDomain
905
+ format: @" `FirebaseApp.configure()` could not find the default "
906
+ @" configuration plist in your project, but did find one at "
907
+ @" %@ . Please rename this file to GoogleService-Info.plist to "
908
+ @" use it as the default configuration." ,
909
+ path];
910
+ }
911
+ }
912
+ }
913
+ }
914
+ }
915
+ #endif // DEBUG
916
+
886
917
@end
0 commit comments