多个GoogleService-Info支持

我将我的Dev和Prod计划注册为Firebase中的不同应用程序。 我希望他们是分开的,每个都有唯一的包ID。 我正在使用#if dev来确定它是否是dev或prodscheme。 我怎样才能为这个计划初始化一个专门的plist的firebase?

只要使用[FIRApp configureWithOptions:]

NSString *firebasePlist = [[NSBundle mainBundle] pathForResource:@"GoogleService-Info" ofType:@"plist"]; #if STAGING firebasePlist = [[NSBundle mainBundle] pathForResource:@"GoogleService-Info-DEV" ofType:@"plist"]; #endif FIROptions *options = [[FIROptions alloc] initWithContentsOfFile:firebasePlist]; [FIRApp configureWithOptions:options]; 

使用

 var firebasePlist: String? = Bundle.main.path(forResource: "GoogleService-Info", ofType: "plist") if development == true{ firebasePlist = Bundle.main.path(forResource: "GoogleService-Info-DEV", ofType: "plist") } var options = FIROptions(contentsOfFile: firebasePlist) FIRApp.configure(with: options) 

但是当您要使用DEV GoogleService plist时,必须有一个名为development的variables,其值为true,而false的值是要使用常规的GoogleService plist