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

Introduction

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 set up iOS environments Using create sandbox and production apps within a single project.

This approach allows you to:

  • Easily switch between environments
  • Streamline your development workflow
  • Avoid common mistakes related to duplicate configuration

We’ll cover various aspects of creating a single project for both sandbox and production apps, including how to set up different configurations, handle data, and manage 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.
    Xcode project navigator showing the project structure for iOS app development
  2. Click on the “Scheme” drop-down menu located in the top-left corner of Xcode and select “Edit Scheme…”.
    Click-on-the-Scheme-drop-down-menu
  3. In the Edit Scheme window, click on the “Manage Schema” button in the bottom-left corner to add a new scheme.
    Click-on-the-Scheme-drop-down-menu
  4. In the Manage Scheme window, click on the “+” button in the bottom-left corner to add a new scheme.
    Click-on-the-Scheme-drop-down-menu

    After clicking on the “+” button open popup to enter your schema name. (etc Sample Project Production)

    Click-on-the-Scheme-drop-down-menu
  5. Name the new scheme to reflect the environment it will be used for (e.g., Sandbox, Production).
    Xcode manage schemes window showing sandbox and production scheme names configured for the project
  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 it according to your feasible bundle identifier. Check the below screenshot for that.
      Xcode build settings showing different product bundle identifiers configured for sandbox and production schemes
    3. You can also double check bundle identifiers for sandbox and production apps in the General section. Check below screenshot
      Xcode general settings tab showing bundle identifier verification for sandbox and production app configurations
  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
      Xcode build settings menu showing the Add User-Defined Setting option for custom configuration values
    3. Add “App Name” in User-Defined Settings.
      Xcode user-defined settings showing App Name and Base URL variables configured for sandbox and production
    4. We set “App_Name” in the “Display Name” of the General Section.
      Xcode general settings showing display name field configured with the APP_NAME user-defined variable
    5. After setting $(APP_NAME) as the display name then the display name looks like the below.
      Xcode showing the resolved display name after applying the APP_NAME variable for sandbox and production schemes
  10. Maintain sandbox and production app API base URL using build settings. So follow the below steps:
    1. Go To Build Setting -> Top left corner tap the “+” icon.
    2. Add User-Defined Setting
      Xcode build settings menu showing the Add User-Defined Setting option for custom configuration values
    3. Check the below screenshot on how to add baseurl.
    4. This “APP_BASE_URL” is set into an info.plist file as “BaseUrl” properties.
      Xcode Info.plist configuration showing BaseUrl property linked to the APP_BASE_URL user-defined build setting
    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.

Also Read: Xero iOS PKCE Guide

static let baseURL = Bundle.main.object(forInfoDictionaryKey: "BaseURL") as! String
Article by

Chintan Prajapati

Chintan Prajapati, a seasoned computer engineer with over 20 years in the software industry, is the Founder and CEO of Satva Solutions. His expertise lies in Accounting & ERP Integrations, RPA, and developing technology solutions around leading ERP and accounting software, focusing on using Responsible AI and ML in fintech solutions. Chintan holds a BE in Computer Engineering and is a Microsoft Certified Professional, Microsoft Certified Technology Specialist, Certified Azure Solution Developer, Certified Intuit Developer, Certified QuickBooks ProAdvisor and Xero Developer.Throughout his career, Chintan has significantly impacted the accounting industry by consulting and delivering integrations and automation solutions that have saved thousands of man-hours. He aims to provide readers with insightful, practical advice on leveraging technology for business efficiency.Outside of his professional work, Chintan enjoys trekking and bird-watching. Guided by the philosophy, "Deliver the highest value to clients". Chintan continues to drive innovation and excellence in digital transformation strategies from his base in Ahmedabad, India.