How to set up iOS environments Using Xcode Schemes: Production and Sandbox

By: Hardik
Updated: February 27, 2023

Welcome to our guide on creating sandbox and production apps within a single project. When developing mobile applications, it’s essential to test and deploy them in different environments to ensure their quality and functionality. However, managing two separate projects for sandbox and production apps can be challenging and time-consuming.

In this article, we’ll show you how to create sandbox and production apps within a single project. By using this approach, you can easily switch between environments, streamline your development process, and avoid common mistakes that can arise from managing separate projects.

We’ll cover various aspects of creating a single project for both sandbox and production apps, including how to set up different configurations, handling data, and managing resources. With our step-by-step instructions and best practices, you’ll be able to create a more efficient and organized workflow for your mobile app development.

Whether you’re a seasoned developer or just starting out, this guide will provide you with valuable insights into managing sandbox and production apps within a single project. So, let’s dive in and learn how to create a more streamlined development process for your mobile applications!

To create two schemes for a sandbox and production app in Xcode, follow these steps:

  1. Open your Xcode project and select the project in the Project Navigator.
  2. Click on the “Scheme” drop-down menu located in the top-left corner of Xcode and select “Edit Scheme…”.
  3. In the Edit Scheme window, click on the “Manage Schema” button in the bottom-left corner to add a new scheme.
  4. In the Manage Scheme window, click on the “+” button in the bottom-left corner to add a new scheme.

    After clicking on the “+” button open popup to enter your schema name.(etc Sample Project Production)
  5. Name the new scheme to reflect the environment it will be used for (e.g., Sandbox, Production).
  6. Select the target for the new scheme from the “Build” tab.
  7.  Customize any additional settings, such as the Run or Test configurations, as desired.
  8. We can set two different bundle identifiers according to the sandbox and production app. So during the build release time we don’t want to edit the bundle identifier every time. Please follow the below steps for that.
    1. Go To Build Setting -> Check Packaging -> Open Product Bundle Identifier
    2. You can set according to your feasible bundle identifier. Check below screenshot for that.
    3. You can also double check bundle identifiers for sandbox and production apps in the General section. Check below screenshot
  9. We can set the display name according to the sandbox and production app. Follow the steps below.
    1. Go To Build Setting -> Top left corner tap “+” icon.
    2. Add User-Defined Setting
    3. Add “App Name” in User-Defined Settings.
    4. We set “App_Name” in the “Display Name” of the General Section.
    5. After setting $(APP_NAME) as display name then the display name looks like below.
  10. Maintain sandbox and production app api base url using build settings. So follow below steps:
    1. Go To Build Setting -> Top left corner tap “+” icon.
    2. Add User-Defined Setting
    3. Check below screenshot how to add baseurl.
    4. This “APP_BASE_URL” is set into an info.plist file as “BaseUrl” properties.
    5. “BaseUrl” property we will get into our code using the below line. You can set this variable as constant and use it anywhere in the whole project.
Copy to Clipboard