I am using a build scheme for prod and one for staging (with 2 different bundle identifiers) and I am trying to use a separate GoogleService-Info.plist for each scheme. Is t
I noticed that google expects the filename to be GoogleServiceInfo.plist in the code:
* The method |configureWithError:| will read from the file GoogleServices-Info.plist bundled with
* your app target for the keys to configure each individual API. To generate your
* GoogleServices-Info.plist, please go to https://developers.google.com/mobile/add
*
* @see GGLContext (Analytics)
* @see GGLContext (SignIn)
*/
@interface GGLContext : NSObject
the key phrase is this one
read from the file GoogleServices-Info.plist bundled with your app target
So I simply copied the same file and put it into different directories, and bounded it to different targets:
Here's how to do it in Xamarin C#:
string plistPath = NSBundle.MainBundle.PathForResource ("GoogleService-Info", "plist");
Options options = new Options (plistPath);
App.Configure (options);
Remember to include the Firebase namespace:
using Firebase.Analytics;
I think you can use this way to configure your GoogleService-Info.plist dynamicly and use different names for different bundle identifiers.
ciao Andreas
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"GoogleService-Info" ofType:@"plist"];
FIROptions *options = [[FIROptions alloc] initWithContentsOfFile:filePath];
[FIRApp configureWithOptions:options];
I solved this by this:
#if STAGING
if let filePath = Bundle.main.path(forResource: "GoogleService-Info-Dev", ofType: "plist"),
let options = FirebaseOptions(contentsOfFile: filePath) {
FirebaseApp.configure(options: options)
} else {
fatalError("GoogleService-Info-Dev.plist is missing!")
}
#else
if let filePath = Bundle.main.path(forResource: "GoogleService-Info", ofType: "plist"),
let options = FirebaseOptions(contentsOfFile: filePath) {
FirebaseApp.configure(options: options)
} else {
fatalError("GoogleService-Info.plist is missing!")
}
#endif
This answer is very much inspired by @abbood's answer, but a bit more specific on how to do it.
For each of your targets, e.g. dev, stg, prod:
GoogleService-Info.plist
to a separate folder named after your targetAdd files to "your app"
GoogleService-Info.plist
, make sure Copy items if needed
and Create groups
are selected, check only the corresponding target in the list of targets, and press Add
That's it. Now you should have something similar to this structure
When you build a target, the correct GoogleService-Info.plist
will be used.