Technology & Design

Creating a Different Build Environment for iOS with API integration

We all know that we have Different Environments during the development of a project, we might have to jump around between Local, QA, Stage, Development, Production these Environments.

And all environments have their own values of Token, Service URL, Socket URL

Obviously, we have stored this all values in some constant file, but we can’t Commenting and Uncommenting environment values every time

That’s why This setup will help you to get rid of this type of Problems with different Environments.

First Step

Go to your project target and Duplicate the Target

Xcode will create sample copy-info.plist file for you in the root directory, you can drag it with main Info Plist.

Now Xcode will name it to sample copy, you have to change it to something appropriate like – sample Dev Or you can keep as it is if you want to.

You have to change the name at,

  1. Sample Copy-Info.plist
  2. Target – you can change it by Click enter on Target
  3. Scheme Name (Right side from Run button) – Go to Manage Scheme – Select Build – Enter

Second Step

Go to new Target – Build Settings (All) – Swift Compiler – Custom Flags – Other Swift Flags – Enter

Here you are defining flag that will differ all the values from Actual Environment

Type “-DEVELOPMENT

 

Third Step

Create Swift file named EnvironmentConstant.swift

Remove Everything from File

add this

That’s it You are done. now you have two schemes and both have different EndPoints.

 

One More IMPORTANT THING

Whenever you create any file then you must add to both targets. otherwise, that file will not available in other Schemes.

You can add it from File Inspector.

 

You can Download Project with Different Environment from gitlab

Published by
Janki Thaker

Recent Posts

  • AI

Copilot Studio vs M365 Copilot: Which One Does Your Business Actually Need?

No vendor pitch here, just the plain difference, so…

2 weeks ago
  • Automation

Before You Automate: The 5-Process Audit Every Operations Director Should Run First

A process automation audit tells you which workflows are…

3 weeks ago
  • Automation

RPA Governance Without a Full IT Team: How Lean Operations Teams Keep Automations Running

Launching an automation is exciting. Keeping it running a…

3 weeks ago
  • Automation

3 Steps to Achieve Versioning and Drafts

Businesses are quickly shifting towards optimized processes. And the…

1 month ago
  • Automation

What Happens to Your RPA Program When Your ERP Upgrades? A Migration Playbook

Enterprise leaders usually celebrate when a major ERP modernization…

2 months ago
  • Automation

RPA Center of Excellence: Setup, Governance, and Scaling

Here's how to build the operating model that turns…

2 months ago