I have a projects with multiple schemes (Not targets).
I have Dev, QA and Prod and I want to add Firebase Analytics and Crashlytics to all of the schemes note that each scheme has its own Bundle id and different name.
How can I achieve this this?
I have a projects with multiple schemes (Not targets).
I have Dev, QA and Prod and I want to add Firebase Analytics and Crashlytics to all of the schemes note that each scheme has its own Bundle id and different name.
How can I achieve this this?
2
Answers
Tested on Xcode 13.3.X
Assuming you already have a Google Firebase account and opened an app in the Firebase console add an app in the console for iOS.
Follow the steps and register your Bundle id for the app now for each scheme (Dev, QA and Prod) you will need to register a different app with different Bundle id and download the GoogleService-Info.plist file DO NOT rename the Plist files.
In your Xcode project Create separate folders for each environment drag each GoogleService-Info.plist files to their folder and Uncheck Copy to target.
In your pod file add pod 'Firebase/Crashlytics' (if you are also using analytics add the pod) and run pod install in the terminal.
After this go to pods target (this is a bug that google suggested a workaround for) and search Apple Clang - Warnings - All Languages and set Quoted include in Framework Header to NO).
After this Go to your target Build Settings under Build Options -> Debug Information Format set all to :
DWARF with dSYM File
On Build Phase tab in the Target add 2 Run Scripts.
The first call Firebase Plist selector (or any other name you want just make sure it runs BEFORE the script to upload the dSYM) and add the following script :
Here you are checking for the GoogleService-Info.plist file for each scheme (note where it says /Environment/Dev QA Prod etc change it to your folder path) if the file is found then it will be added in build time and the correct Plist file will be added to the build each time.
Now in the second script add this:
And under Input Files add these 2:
Clean and build project if everything is correct when your enter the Crashlytics part in the console and simulate a crash (you can put fatalError on a IBAction or Button action to simulate) and you will be able to see your crash for each scheme you configured.
As a note if you wish to copy a folder use :
This will copy the folder and all its contents.
Very important to add a / at the end of the name for example change
to
Kindest regards.
if you have multple scheme on just one target:
you can change plist files following the scheme like this:
in this code I have two schem one is Dev other is Prod