{"id":63235,"date":"2024-08-07T22:36:29","date_gmt":"2024-08-07T17:06:29","guid":{"rendered":"https:\/\/www.tothenew.com\/blog\/?p=63235"},"modified":"2024-08-08T10:19:20","modified_gmt":"2024-08-08T04:49:20","slug":"firebase-configuration-for-multiple-environments","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/firebase-configuration-for-multiple-environments\/","title":{"rendered":"How to configure iOS apps for multiple environments (Dev, QA, Prod)"},"content":{"rendered":"<p>In this blog, we are going to learn something related to project scheme configurations. As we proceed with a project we have to manage environments (<strong>Development, QA, Staging, Production<\/strong>) and when we use different environments there are different server URLs, icons, Plist files, and configurations for each environment. While creating a project, a scheme is created by default and still is not configured as per our needs, It\u2019s tough to manage things while sharing builds in a bottleneck situation. So we will create schemes, that can manage all these hassles at the time of sharing build for a particular environment<\/p>\n<h2>Now there comes a question, how to manage configuration automatically by switching schemes (Environment)?<\/h2>\n<p>Starting with <strong>Creating Schemes and their Configurations<\/strong><\/p>\n<p>Now, Setup a Project :<\/p>\n<p>Open XCode,\u00a0select Create New Project &gt; \u00a0Apps &gt;\u00a0 add a name.<\/p>\n<p><strong>Create schemes and Add configuration :<\/strong><\/p>\n<p>Here, we need to understand that when an Xcode scheme is created it creates two different build Configurations, i.e. Debug and Release, Now here if we need to, we can configure these as per our requirement for a particular environment.<\/p>\n<p><strong>Step 1:<\/strong>\u00a0 To add our build configurations, Select Project from the Project Navigator Pane from the left, and Select Info from the options<\/p>\n<p><strong>Step 2:<\/strong>\u00a0 Now in Configuration, Add your configuration for the environments (<em>like- Development, QA, Staging, Production etc<\/em>.)<\/p>\n<p>Click on the <strong>+<\/strong> icon showing Duplicate Debug Configuration, to add multiple configurations repeat these steps as needed. Double click on the Debug and you can rename it Like Development, QA, Staging and Production like the image below.<\/p>\n<div>\n<div id=\"attachment_63491\" style=\"width: 810px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-63491\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-63491\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-28-at-9.59.18\u202fPM-1024x189.png\" alt=\"Default Configuration\" width=\"800\" height=\"148\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-28-at-9.59.18\u202fPM-1024x189.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-28-at-9.59.18\u202fPM-300x55.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-28-at-9.59.18\u202fPM-768x142.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-28-at-9.59.18\u202fPM-1536x283.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-28-at-9.59.18\u202fPM-624x115.png 624w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-28-at-9.59.18\u202fPM.png 1864w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><p id=\"caption-attachment-63491\" class=\"wp-caption-text\">Default Configuration<\/p><\/div>\n<div id=\"attachment_63492\" style=\"width: 681px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-63492\" decoding=\"async\" loading=\"lazy\" class=\" wp-image-63492\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-28-at-10.03.32\u202fPM-1024x310.png\" alt=\"Create Configuration for all Environment\" width=\"671\" height=\"203\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-28-at-10.03.32\u202fPM-1024x310.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-28-at-10.03.32\u202fPM-300x91.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-28-at-10.03.32\u202fPM-768x233.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-28-at-10.03.32\u202fPM-1536x465.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-28-at-10.03.32\u202fPM-624x189.png 624w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-28-at-10.03.32\u202fPM.png 1816w\" sizes=\"(max-width: 671px) 100vw, 671px\" \/><p id=\"caption-attachment-63492\" class=\"wp-caption-text\">Create Configuration for all Environment<\/p><\/div>\n<\/div>\n<div>\n<div>\n<div id=\"attachment_63493\" style=\"width: 676px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-63493\" decoding=\"async\" loading=\"lazy\" class=\" wp-image-63493\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-28-at-10.07.24\u202fPM.png\" alt=\"Add Duplicate Configuration for Environment\" width=\"666\" height=\"209\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-28-at-10.07.24\u202fPM.png 1802w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-28-at-10.07.24\u202fPM-300x94.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-28-at-10.07.24\u202fPM-1024x322.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-28-at-10.07.24\u202fPM-768x241.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-28-at-10.07.24\u202fPM-1536x482.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-28-at-10.07.24\u202fPM-624x196.png 624w\" sizes=\"(max-width: 666px) 100vw, 666px\" \/><p id=\"caption-attachment-63493\" class=\"wp-caption-text\">Add Duplicate Configuration for Environment<\/p><\/div>\n<\/div>\n<\/div>\n<div>\n<div><\/div>\n<div>\n<div id=\"attachment_63495\" style=\"width: 677px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-63495\" decoding=\"async\" loading=\"lazy\" class=\" wp-image-63495\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-28-at-10.44.02\u202fPM-900x1024.png\" alt=\"Add and update scheme configuration\" width=\"667\" height=\"759\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-28-at-10.44.02\u202fPM-900x1024.png 900w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-28-at-10.44.02\u202fPM-264x300.png 264w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-28-at-10.44.02\u202fPM-768x874.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-28-at-10.44.02\u202fPM-1350x1536.png 1350w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-28-at-10.44.02\u202fPM-624x710.png 624w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-28-at-10.44.02\u202fPM.png 1540w\" sizes=\"(max-width: 667px) 100vw, 667px\" \/><p id=\"caption-attachment-63495\" class=\"wp-caption-text\">Add and update scheme configuration<\/p><\/div>\n<\/div>\n<p>Add the configuration file for each scheme, In this file, Add all dependencies related to particular environments (<em>like ServerURL, icons and other configurations<\/em>) as required.<\/p>\n<div>\n<div id=\"attachment_63496\" style=\"width: 670px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-63496\" decoding=\"async\" loading=\"lazy\" class=\" wp-image-63496\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-11.48.21\u202fAM-1024x446.png\" alt=\"Showing Configuration file\" width=\"660\" height=\"288\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-11.48.21\u202fAM-1024x446.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-11.48.21\u202fAM-300x131.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-11.48.21\u202fAM-768x335.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-11.48.21\u202fAM-1536x670.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-11.48.21\u202fAM-2048x893.png 2048w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-11.48.21\u202fAM-624x272.png 624w\" sizes=\"(max-width: 660px) 100vw, 660px\" \/><p id=\"caption-attachment-63496\" class=\"wp-caption-text\">Showing Development Configuration file<\/p><\/div>\n<\/div>\n<div>\n<div id=\"attachment_63498\" style=\"width: 670px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-63498\" decoding=\"async\" loading=\"lazy\" class=\" wp-image-63498\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-12.09.16\u202fPM-2-1024x179.png\" alt=\"Access Environment variables\" width=\"660\" height=\"115\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-12.09.16\u202fPM-2-1024x179.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-12.09.16\u202fPM-2-300x52.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-12.09.16\u202fPM-2-768x134.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-12.09.16\u202fPM-2-1536x268.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-12.09.16\u202fPM-2-624x109.png 624w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-12.09.16\u202fPM-2.png 1958w\" sizes=\"(max-width: 660px) 100vw, 660px\" \/><p id=\"caption-attachment-63498\" class=\"wp-caption-text\">Access Environment variables<\/p><\/div>\n<p><strong>Step 3:\u00a0<\/strong> For the Development Scheme configuration file content, keys are added to the screen above, to fetch the environment variable when needed. Showing the steps for the Development Environment, repeated it for each environment.<\/p>\n<div>\n<p><strong>Step 4:<\/strong> Link your configuration file and pod configuration file with each created environment. After adding all the settings it will look something like this<\/p>\n<\/div>\n<div id=\"attachment_63499\" style=\"width: 635px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-63499\" decoding=\"async\" loading=\"lazy\" class=\"size-large wp-image-63499\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-11.59.26\u202fAM-2-1024x699.png\" alt=\"Link configuration file for environment\" width=\"625\" height=\"427\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-11.59.26\u202fAM-2-1024x699.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-11.59.26\u202fAM-2-300x205.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-11.59.26\u202fAM-2-768x525.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-11.59.26\u202fAM-2-1536x1049.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-11.59.26\u202fAM-2-624x426.png 624w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-11.59.26\u202fAM-2.png 1956w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><p id=\"caption-attachment-63499\" class=\"wp-caption-text\">Link configuration file for environment<\/p><\/div>\n<div id=\"attachment_63500\" style=\"width: 635px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-63500\" decoding=\"async\" loading=\"lazy\" class=\"size-large wp-image-63500\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-11.59.38\u202fAM-2-1024x666.png\" alt=\"Link Pod configuration file for selected scheme\" width=\"625\" height=\"406\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-11.59.38\u202fAM-2-1024x666.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-11.59.38\u202fAM-2-300x195.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-11.59.38\u202fAM-2-768x499.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-11.59.38\u202fAM-2-1536x998.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-11.59.38\u202fAM-2-624x406.png 624w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-11.59.38\u202fAM-2.png 1966w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><p id=\"caption-attachment-63500\" class=\"wp-caption-text\">Link Pod configuration file for the selected scheme<\/p><\/div>\n<div>\n<div>\n<div id=\"attachment_63501\" style=\"width: 635px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-63501\" decoding=\"async\" loading=\"lazy\" class=\"size-large wp-image-63501\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-12.03.00\u202fPM-2-1024x693.png\" alt=\"Showing environment configuration file linked with selected schemes\" width=\"625\" height=\"423\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-12.03.00\u202fPM-2-1024x693.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-12.03.00\u202fPM-2-300x203.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-12.03.00\u202fPM-2-768x520.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-12.03.00\u202fPM-2-1536x1039.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-12.03.00\u202fPM-2-624x422.png 624w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-12.03.00\u202fPM-2.png 1960w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><p id=\"caption-attachment-63501\" class=\"wp-caption-text\">Showing environment configuration file linked with selected schemes<\/p><\/div>\n<\/div>\n<p>There is one more trick to do that, for <strong>Step 4<\/strong><strong>:<\/strong> Just follow the process which is shown in the image below:<\/p>\n<div id=\"attachment_63747\" style=\"width: 641px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-63747\" decoding=\"async\" loading=\"lazy\" class=\" wp-image-63747\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/08\/Screenshot-2024-08-02-at-11.39.59\u202fPM.png\" alt=\"Add path of pod xcconfig here in environment config file\" width=\"631\" height=\"739\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/08\/Screenshot-2024-08-02-at-11.39.59\u202fPM.png 1206w, \/blog\/wp-ttn-blog\/uploads\/2024\/08\/Screenshot-2024-08-02-at-11.39.59\u202fPM-256x300.png 256w, \/blog\/wp-ttn-blog\/uploads\/2024\/08\/Screenshot-2024-08-02-at-11.39.59\u202fPM-875x1024.png 875w, \/blog\/wp-ttn-blog\/uploads\/2024\/08\/Screenshot-2024-08-02-at-11.39.59\u202fPM-768x899.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/08\/Screenshot-2024-08-02-at-11.39.59\u202fPM-624x731.png 624w\" sizes=\"(max-width: 631px) 100vw, 631px\" \/><p id=\"caption-attachment-63747\" class=\"wp-caption-text\">Add the path of pod .xcconfig here in the environment config file<\/p><\/div>\n<div id=\"attachment_63748\" style=\"width: 642px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-63748\" decoding=\"async\" loading=\"lazy\" class=\" wp-image-63748\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/08\/Screenshot-2024-08-02-at-11.36.40\u202fPM.png\" alt=\"select environment configuration file as per configuration.\" width=\"632\" height=\"247\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/08\/Screenshot-2024-08-02-at-11.36.40\u202fPM.png 1628w, \/blog\/wp-ttn-blog\/uploads\/2024\/08\/Screenshot-2024-08-02-at-11.36.40\u202fPM-300x117.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/08\/Screenshot-2024-08-02-at-11.36.40\u202fPM-1024x400.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2024\/08\/Screenshot-2024-08-02-at-11.36.40\u202fPM-768x300.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/08\/Screenshot-2024-08-02-at-11.36.40\u202fPM-1536x600.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2024\/08\/Screenshot-2024-08-02-at-11.36.40\u202fPM-624x244.png 624w\" sizes=\"(max-width: 632px) 100vw, 632px\" \/><p id=\"caption-attachment-63748\" class=\"wp-caption-text\">Select the environment configuration file as per configuration.<\/p><\/div>\n<p>Now all the schemes with their respective environment are linked. There is one last step to working on\u00a0this configuration properly.<\/p>\n<p><strong>Step 5:<\/strong> Select any scheme -&gt; edit scheme -&gt; and set your desired configuration.<\/p>\n<div id=\"attachment_63214\" style=\"width: 635px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-63214\" decoding=\"async\" loading=\"lazy\" class=\"size-large wp-image-63214\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-12.07.49\u202fPM-1024x543.png\" alt=\"Final Step for Environment Scheme Configuration\" width=\"625\" height=\"331\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-12.07.49\u202fPM-1024x543.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-12.07.49\u202fPM-300x159.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-12.07.49\u202fPM-768x407.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-12.07.49\u202fPM-1536x814.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-12.07.49\u202fPM-624x331.png 624w, \/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-12.07.49\u202fPM.png 1880w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><p id=\"caption-attachment-63214\" class=\"wp-caption-text\">The final step to achieving Environment Scheme configuration<\/p><\/div>\n<div><\/div>\n<p>The project is ready to run for multiple Schemes and the configuration setup is completed:<\/p>\n<p>Select scheme from drop down and run \u2014 the environment will be automatically configured as required<\/p>\n<pre style=\"padding-left: 40px;\"><strong>var\u00a0<\/strong><span style=\"color: #008080;\"><em>environment<\/em><\/span>: <span style=\"color: #0000ff;\"><strong>String<\/strong><\/span> {\r\n\r\n\u00a0 \u00a0 \u00a0 \u00a0 let env = <strong><span style=\"color: #800080;\">Bundle<\/span><\/strong>.<span style=\"color: #008000;\">main<\/span>.<span style=\"color: #008000;\">infoDictionary<\/span>![\"<span style=\"color: #993300;\">ENVIRONMENT<\/span>\"] <span style=\"color: #333399;\">as<\/span>? <span style=\"color: #0000ff;\"><strong>String<\/strong><\/span> ?? \"\"\r\n\r\n\u00a0 \u00a0 \u00a0 \u00a0 <strong><span style=\"color: #800080;\">return<\/span><\/strong> env \r\n\r\n}<\/pre>\n<\/div>\n<div>\n<pre style=\"padding-left: 40px;\"><strong>var<\/strong> <span style=\"color: #008080;\">hostURL<\/span>: <strong><span style=\"color: #0000ff;\">String<\/span><\/strong> {\r\n\r\n\u00a0 \u00a0 \u00a0 \u00a0 let env = <span style=\"color: #800080;\">Bundle<\/span>.<span style=\"color: #339966;\">main<\/span>.<span style=\"color: #008080;\">infoDictionary<\/span>![\"<span style=\"color: #993366;\">HOST_URI<\/span>\"] <span style=\"color: #3366ff;\">as<\/span>? <span style=\"color: #0000ff;\">String<\/span> ?? \"\"\r\n\r\n\u00a0 \u00a0 \u00a0 \u00a0 <strong><span style=\"color: #993366;\">return<\/span><\/strong> env\r\n\r\n}<\/pre>\n<h2><strong>Firebase Crashlytics for Multiple Environment<\/strong><\/h2>\n<p><strong>Why do we need Multi-Environment Configuration for Firebase Crashlytics?<\/strong><\/p>\n<p>Using multi-environment configuration for Firebase Crashlytics allows you to manage and separate the data and settings for different stages of your app development process, such as development, staging, and production. Here are several reasons why this is beneficial:<\/p>\n<ol>\n<li><strong>Environment Separation:<\/strong><br \/>\nBy using different configurations for each environment, you can keep your crash reports organized. This helps in distinguishing crashes occurring in the development phase from those in production.<\/li>\n<li><strong>Focused Debugging:<\/strong><br \/>\nCrashes in the development environment can be addressed without interference from production data. This allows for more focused debugging and testing.<\/li>\n<li><strong>Data Privacy and Security:<\/strong><br \/>\nKeeping production data separate ensures that sensitive user data and logs from the production environment are not accessible in development or staging environments, enhancing security and privacy.<\/li>\n<li><strong>Release Management:<\/strong><br \/>\nDifferent configurations help in managing releases and hotfixes more effectively. You can test new features and fixes in staging before deploying them to production.<\/li>\n<li><strong>Performance Optimization:<\/strong><br \/>\nIt allows for performance monitoring and crash reporting to be tailored to each environment&#8217;s specific needs, optimizing resource usage and ensuring that performance metrics are accurate for each stage of the app lifecycle.<\/li>\n<li><strong>Compliance and Monitoring:<\/strong><br \/>\nDifferent environments can have different compliance requirements. Multi-environment configurations help in meeting these requirements by ensuring that only relevant data is collected and monitored.<br \/>\nOverall, the multi-environment configuration for Firebase Crashlytics provides a structured and efficient way to manage, monitor, and respond to crashes throughout the app development lifecycle.<\/li>\n<\/ol>\n<p>To create a separate Firebase environment<\/p>\n<p><strong>Step 1:<\/strong> Create\/add a project<\/p>\n<div>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-1.14.32\u202fPM.png\" alt=\"Create or add Project\" width=\"721\" height=\"77\" \/><\/a><\/p>\n<\/div>\n<p><strong>Step 2: <\/strong>Add Project with a bundle ID you have for each environment<\/p>\n<div>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-1.17.43\u202fPM.png\" alt=\"Apps with All Environment\" width=\"730\" height=\"575\" \/><\/a><\/p>\n<\/div>\n<p><strong>Step 3:<\/strong> Now download <strong>GoogleService-info.plist<\/strong> for each environment<\/p>\n<p>Make a folder in a project and name it, as I have shown a folder named Firebase, and add a folder for each environment and name it as schemes (<strong>Development, QA, Staging, Production<\/strong>). These folders will contain <strong>GoogleService-info.plist<\/strong> for each environment\u00a0 downloaded from the Firebase console as shown<\/p>\n<div>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-1.29.19\u202fPM.png\" alt=\"PlistFile\" width=\"712\" height=\"179\" \/><\/a><\/p>\n<\/div>\n<div>\n<p><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-1.30.59\u202fPM.png\" alt=\"TargetFiles\" width=\"346\" height=\"172\" \/><\/a><\/p>\n<\/div>\n<p>Make sure for all the <strong>GoogleService-info.plist<\/strong> in every environment folder -&gt; the Target Membership is unchecked because these will be handled from a script<\/p>\n<p><strong>Step 4:<\/strong> Now go to Project and select <strong>Targets<\/strong> -&gt; Go to <strong>Build Phases<\/strong> -&gt; click on <strong>+<\/strong> icon here -&gt; Click <strong>New Run Script Phase<\/strong><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-1.41.06\u202fPM.png\" alt=\"Add Run Script\" width=\"719\" height=\"160\" \/><\/a><\/p>\n<p>Add these script codes to your <strong>New Run Script<\/strong> <strong>Phase<\/strong> <span style=\"color: #3366ff;\"><a style=\"color: #3366ff;\" href=\"https:\/\/gist.github.com\/Vibhashkumar2022\/13d7fa201cfbe3eb78ff18d096efb411\">Gist link please click here<\/a><\/span><\/p>\n<\/div>\n<\/div>\n<div>\n<div>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-17-at-1.44.46\u202fPM.png\" alt=\"Run Script\" width=\"738\" height=\"624\" \/><\/p>\n<\/div>\n<p>Build now -&gt; On successful building of code.<\/p>\n<div>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/07\/Screenshot-2024-07-10-at-5.00.37\u202fPM.png\" alt=\"Script Exicution\" width=\"737\" height=\"235\" \/><\/a><\/p>\n<\/div>\n<p><strong>Conclusion:<\/strong><\/p>\n<p>Implementing multiple configurations is often useful in the App development life cycle as it enables the developer to develop, integrate, test, and deploy the App individually for every environment resulting in better tracking of analytics, crashes, and environment-related data. Make sure the Firebase Crashlytics Configuration is implemented properly, to re-evaluate use the following points:<\/p>\n<p><strong>1. Verify Configurations:<\/strong><br \/>\nConfirm that each environment has its own Firebase App\/Project and configuration file (e.g. GoogleService-Info.plist for iOS). Ensure that the correct configuration file is included in the build for each environment.<br \/>\n<strong>2. Test Integration:<\/strong><br \/>\nTrigger a crash in each environment to ensure Crashlytics is correctly logging crashes. This can be done by adding a test crash code snippet (fatalError()). Verify that the crash reports appear in the Firebase Console under the desired app\/project.<br \/>\n<strong>3. Check Console Data:<\/strong><br \/>\nGo to the <strong>Firebase Console<\/strong> to confirm that crashes are logged in the correct environments.<\/p>\n<p><strong>Note: You can access the complete code at <span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/github.com\/Vibhashkumar2022\">GitHub<\/a>.<\/span><br \/>\nSample code: \u00a0 <span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/github.com\/Vibhashkumar2022\/ME-FirebaseConfigurationApp\">https:\/\/github.com\/Vibhashkumar2022\/ME-FirebaseConfigurationApp<\/a>\u00a0<\/span><\/strong><\/p>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this blog, we are going to learn something related to project scheme configurations. As we proceed with a project we have to manage environments (Development, QA, Staging, Production) and when we use different environments there are different server URLs, icons, Plist files, and configurations for each environment. While creating a project, a scheme is [&hellip;]<\/p>\n","protected":false},"author":1630,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":517},"categories":[1400],"tags":[6140,6138,6134,6135,6139,6137,6136],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/63235"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/1630"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=63235"}],"version-history":[{"count":22,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/63235\/revisions"}],"predecessor-version":[{"id":63891,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/63235\/revisions\/63891"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=63235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=63235"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=63235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}