使用多个方案添加firebase Analytics和Crashlytics在iOS项目中
我有一个具有多个方案的项目(不是目标)。 我有开发人员,QA和产品,我想在所有方案中添加firebase Analytics和crashlytics,请注意,每个方案都有自己的捆绑包ID和不同的名称。
我该如何实现这一目标?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您仅在一个目标上有多个方案:
您可以按照这样的方案更改PLIST文件:
在此代码中,我有两个schem一个是dev另一个是prod
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
在Xcode 13.3.3上进行了测试
假设您已经拥有一个Google Firebase帐户,并在Firebase Console中打开了一个应用程序,则
。请按照这些步骤进行步骤,并为每个方案(DEV,QA和prod)注册您的应用程序ID,您将需要注册一个使用不同的捆绑包ID的其他应用程序,然后下载GoogleService-info.plist文件,请勿重命名PLIST文件。
在您的Xcode项目中,为每个环境创建单独的文件夹,将每个GoogleService-Info.plist文件拖到其文件夹,然后取消选中副本到Target。
在您的POD文件中,添加POD“ firebase/crashlytics”(如果您还使用分析添加POD)并在终端中运行POD安装。
在此之后,转到PODS目标(这是Google建议解决方法的错误),并搜索Apple Clang-警告 - 所有语言,并引用的所有语言都包含在框架标题中为NO)。
此后,转到您的目标构建设置下的构建选项 - >调试信息格式将全部设置为:
DSYM文件的矮dwarf
在目标添加2个运行脚本中的构建阶段选项卡上的
。第一个调用firebase plist选择器(或您想要的任何其他名称,只需确保其在脚本之前运行以上载DSYM)并添加以下脚本:
在此处,您正在检查每个方案的GoogleService-info.plist文件(请注意,请注意它说 /环境 /开发QA产品等将其更改为您的文件夹路径)如果找到该文件,则将在构建时间中添加,并且每次都会将正确的PLIST文件添加到构建中。
现在在第二个脚本中添加以下内容:
并在输入文件下添加以下2:
清洁和构建项目,如果您在控制台中输入crashlytics部分并模拟崩溃(您可以将fatalerror放在ibaction或按钮操作上以模拟) ),您将能够看到您配置的每个方案的崩溃。
请注意,如果您想复制文件夹使用:
这将复制文件夹及其所有内容。
在名称的末尾添加a /例如更改< / strong>非常
重要
。
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.