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

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. 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, 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.
    Open-your-Xcode-project
  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).
    Name-the-new-scheme-to-reflect
  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.
      You-can-set-according-to-your-feasible-bundle-identifier
    3. You can also double check bundle identifiers for sandbox and production apps in the General section. Check below screenshot
      You-can-also-double-check-bundle
  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
      Add-User-Defined-Setting
    3. Add “App Name” in User-Defined Settings.
      add-baseurl
    4. We set “App_Name” in the “Display Name” of the General Section.
      Display-Name
    5. After setting $(APP_NAME) as the display name then the display name looks like the below.
      After-setting
  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
      Add-User-Defined-Setting
    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.
      APP_BASE_URL
    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: Latest guide on Xero oAuth 2.0 integration with Native iOS app using PKCE

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, 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.