1

My iOS app uses two Firebase configuration files, one for development and one for production. How can I switch between the two during runtime? When I attempt the switch with [FIRApp configureWithOptions:options];, I get the error:

 Default app has already been configured.

So I have tried to clear the current config [FIRApp deleteApp] before switching to the other config, however the deleteApp method is a private method and is not accessible.

user2181948
  • 1,646
  • 3
  • 33
  • 60

2 Answers2

1

Try this when initializing your firebase :

    NSString *filePath;

#ifdef DEBUG
    filePath = [[NSBundle mainBundle] pathForResource:@"GoogleService-Info-Debug" ofType:@"plist"];
#else
    filePath = [[NSBundle mainBundle] pathForResource:@"GoogleService-Info-Live" ofType:@"plist"];
#endif

    FIROptions *options = [[FIROptions alloc] initWithContentsOfFile:filePath];
    [FIRApp configureWithOptions:options];
Fares Benhamouda
  • 589
  • 8
  • 21
1

I was calling the deleteApp method incorrectly. It should be called on defaultApp, eg.:

 [[FIRApp defaultApp] deleteApp:^(BOOL success) { ... }];
user2181948
  • 1,646
  • 3
  • 33
  • 60