iOS Build Management using Custom Build Scheme


One of the best practices in iOS development is to be able to manage multiple environments during the development of a project. Many a time we might have to jump between DEV, QA, STAGE, and Production environments. As the owner of a product, clients request to have both development version of the app and production version of the app i.e. App store released version of the app on the same device.

If you have ever faced or might face this situation, then you need a custom build scheme.


This blog explains the significance of custom build schemes & build configurations in XCode. We will see how we can leverage these to configure an iOS project to support multiple build environments without the need to duplicate targets and keep the same code base.


  • XCode 8.0 onwards
  • Mac machine with macOS Sierra version

Advantages of Custom Builds

  • Write code that only runs on a particular environment. For example, on DEV you might want to have different values to constants in the app than on Production.
  • Switch between different environments easily to deliver a build that talks to the production server after testing your app in a development environment.

Difference Between Build Schemes & Build Configurations

Before we start actual changes on XCode, let’s understand the difference between build schemes & build configurations first.

A build scheme is a blueprint for an entire build process. It is a way of telling Xcode what build configurations you want to use to create the development, unit test, and production builds for a given target (framework or app bundle).

A build configuration is a specific group of builds settings that can be applied to any target.

Most app projects come with two build configurations and one build scheme. You get the debug and release build configurations along with a building scheme that runs the debug configuration for debugging purposes and the release configuration for archiving/submission.

For most projects, this is perfectly fine and requires no tweaking. However, if you want to offer both a DEV and a PRODUCTION version of the same app, it’s not quite enough. You must add a new build configuration to achieve this.

Adding a new build configuration

Whenever you wish to support multiple environments in the app, you need to start by adding a new build configuration. There are some important steps involved which sometimes seems confusing at first, so follow every step carefully.

  1. Open Xcode and select the project file.


2. Go to Editor → Add Configuration → Duplicate Debug Configuration.


Repeat Steps 1 and 2 for Release configuration.
NOTE: Remember that for every environment you must Duplicate Debug and Release configuration. Thus, if you want to support DEV, QA, STAGE, PRO then you should have the following configuration:

  • DEV-Debug, DEV-Release
  • QA-Debug, QA-Release
  • STAGE-Debug, STAGE-Release
  • PRO-Debug, PRO-Release


Creating a separate build scheme for every environment

We’re going to take our new build configurations and create a build scheme that runs them.

  1. Tap on the currently active scheme.
  2. In the dropdown, select New Scheme.


3. Provide a name to the new build scheme. I usually follow <Name of the app>-       <Environment>. For example, MultipleEnvApp-QA.


Once you’ve done this, notice that your new build scheme is selected.


We’re not done yet. We have a build scheme, but it isn’t using our new build configurations yet.

4. Click on your build scheme and select Edit Scheme.


5. Select the appropriate build configuration as per the environment. For example, our selected scheme is MultipleEnvApp-QA, hence choose respective QA build configurations.


That’s it. In the same way, you can create and configure schemes for STAGE and PRO environment. You can rename the default scheme as MultipleEnvApp-DEV

Writing code that runs on a particular environment of your app

Unfortunately, having separate build schemes isn’t quite enough. We also need a way to selectively run blocks of code on a particular environment. To do that, we are going to add a custom Swift flag that only applies to the particular build configurations we just created.

  1. Select the target and then Go to Build Settings, and scroll down to Other Swift Flags.
  2. You must add the flags for every configuration. For example, add the flag “-DQA” to both of the QA build configurations.


-D is the namespace for custom flags that can be passed into a build command.

You can ignore the “-D” for now.

3. Go to any of your source files. For example, AppDelegate and add these lines of code. 

We have created a global variable SOME_SERVICE_KEY and used a unique value for each environment. In this way, you can actually use different service keys, constants for different environments.

Different bundle identifiers for different build configurations

Optionally, if you want to use different bundle ID for different configurations, do the following:

  1. Create two app IDs on your Apple Developer portal.
  2. Go to your project settings and set the appropriate bundle identifiers for different build configurations.



That’s all there is to it. Now you are setup to deliver a configurable app for different environments using the same shared codebase. Here is the GitHub project that contains all the configurations which we followed in this blog.

Happy Coding!

Build an iOS app that connects to IoT device using Bluetooth

You must be aware of term “IoT” Internet of Things, this is one of the hot technology worldwide nowadays, as many products, devices are available in the market.

I won’t say detailed knowledge of IoT, but at the end of this article, you will have a high-level idea of how IoT system works. To understand it, we will create an iOS demo app which will send/receive data from IoT compatible device with the help of Arduino.

In this article, we will cover following points:
– Introduction to IoT
– Arduino Overview
– iOS Demo App to understand end to end flow.

Introduction to IoT
Internet of things is a system of devices connected to the internet with the ability to collect and exchange data. The device or “Thing” in IoT could be any device embedded with electronics, software, and sensors like lights in household, smart air conditioner or person with heart monitor.
Lets see what are the opportunities in IoT, why it became one of the hot technology:
  • The connected world of devices, people and data helps to create numerous business opportunities for many sectors. For example, If I own car parts manufacturing business then I might want to know which parts are most popular. Using IoT, I can use a sensor in a showroom, to detect which areas are more popular or in which area customer spends more time. I will use this data to identify parts and increase production of these parts.
  • Real-time updates offer resources to improve decision making more accurate.
  • Costs of IoT components have significantly gone down, which effectively means that the cost of IoT-linked devices is getting more affordable day by day.

There are many other opportunities which accelerated the market for Internet of Things. It is predicted that by 2020, 25 billion devices will be available in the market.

The network in IoT will be decided on the factors such as range, data, security, and power. These factors will decide the choice of network whether it is the internet, Bluetooth, WiFi or any other. IoT is used for the devices that would not necessary to have an internet connection. It is used for a device that can communicate with the network which can be the internet, Bluetooth, NFC or anything else. For short-range communications technology is of course Bluetooth. It is expected to be key for wearable products. For example, Smartwatch, Fitness band. There are many sources available for IoT, so we will not dig into this.

Arduino Overview

We know how to send or receive data over the internet from an iOS app. But many of us don’t know how this data operate the IoT devices. There are open source hardware and software available in the market which is used to control the IoT devices. One of these is Arduino.

Arduino is an open-source hardware and software. Arduino boards are able to read inputs from the different sensors and turn it into an output like turning on an LED, activating a motor or publishing it over the internet.

These boards can take following inputs and outputs:
  • Temperature, Humidity, Pressure etc
  • Light, Infrared signals
  • Sounds
  • Motion captures
  • Heart rate, muscle movement
  • Electrical current
  • Touch, Fingerprints
  • LEDs
  • LCDs
  • Speakers
  • Motors
  • The internet
There are different types of Arduino boards available depending on features like an ethernet port, wireless or USB device support. Common specification of these hardware boards are:
  • ATmega 328 8bit chip
  • 5-20V power supply
  • 32 KB flash memory
  • 20 I/O pins

You can tell Arduino boards what to do by sending a set of instructions to the microcontroller on the board. For this, we have to use Arduino Software (IDE) and Arduino programming language.

Arduino IDE:

To write code and upload it to the board, Arduino IDE is used. It is available for Mac, Windows, and Linux platform. You can download it at

Arduino programming language:
The coding language that Arduino uses is very much like C++, which is a common language in the world of computing.
Two important functions in Arduino language are:
  • setup( ) – Every program should have this function. This runs once at the start of the program like main () function. You can do initialisation stuff in this function.
  • loop( ) – Every program should have this function. This gets called repeatedly. You can use it to actively control the Arduino board.
Other Useful Function:
  • pinMode() – Set a pin as input or output
  • digitalWrite() – Set a digital pin high/low
  • digitalRead() – Read a digital pin’s state
  • analogRead() – Read an analog pin
  • analogWrite() – Write an analog value
  • delay() – Wait an amount of time
Example Code:
int ledPin = 3;
// setup initializes serial and the LED pin
void setup(){
     pinMode(ledPin, INPUT);

// loop checks the LED pin state each time and broadcast it whether it is high or
// low
void loop(){
    if (digitalRead(ledPin) == HIGH)


You will find more details about language at

Once you write the code, you can upload it on Arduino board by using Arduino IDE. You can download demo Arduino program to turn LED on-off. This program send/receives data over the Bluetooth and turns on-board LED on-off depending on data received. Also, this will broadcast state of the LED pin. You can use Arduino Leonardo board for this demo.

iOS Demo App 
I have created a sample iOS demo app which will send/receive data over the Bluetooth. For that, I have used Core-Bluetooth framework. You can download it here.
On launch of this app, it will try to connect to a nearby Bluetooth device which is Arduino board in our case. After successful connection, this app can send instructions to the board to turn LED on-off.
Steps To Run:
  • Upload LED demo program on Arduino board. You have to upload it by using Arduino IDE. You will find more details for uploading it in the referenced link above.
  • On successful upload, keep power up Arduino board.
  • Launch iOS demo app. It will connect automatically to the board on which program is uploaded.
  • Once it is connected, red line in the app turns green. Now you can send instructions to turn LED on-off on the board by using this app.
  • Once it is connected, red line in the app turns green. Now you can send instructions to turn LED on-off on the board by using this app.

You can modify this demo program for the internet instead of Bluetooth. For internet network, Arduino board which has a capability of broadcasting data over the internet is required.

This article is a good starting point for anyone who is interested in connecting an iOS app to IoT device using Bluetooth Low Energy. We saw how to hook up an Arduino board with an iOS app. We have a LED on Arduino board, but we can easily connect any other sensor to it. You can find the sample projects on github. I hope you’ll find these projects useful. Good luck and have fun!

Build your own custom Android ROM using Android Open Source Project(AOSP)


One of the best things about Android is custom ROMs. A custom Android ROM refers to a phone’s firmware, based on Google’s Android platform. The term ROM, which stands for Read Only Memory, really has very little to do with what a custom Android ROM actually is, can be confusing. Since Android is an open source mobile operating system that means anyone can download the source code, make modification to it, recompile it and release it for a wide variety of devices. Anyone can install ROMs to their device and achieve a modified appearance and behavior. Continue reading Build your own custom Android ROM using Android Open Source Project(AOSP)

Object detection with Turi Create and augmentation using ARKit


Over the past few years, the use of Machine Learning to solve complex problems has been increasing. Machine learning (ML) is a field of computer science that gives computer systems the ability to “learn” (i.e. progressively improve performance on a specific task) with data, without being explicitly programmed.

Last year was a good year for the freedom of information, as titans of the industry Google, Microsoft, Facebook, Amazon, Apple and even Baidu open-sourced their ML frameworks. In this blog, let’s explore a framework provided by Apple named Turi Create. Continue reading Object detection with Turi Create and augmentation using ARKit

OCR implementation in Android

What is OCR?

Optical character recognition, Optical character reader or OCR is the process of reading printed or handwritten text and converting them into machine-encoded text. OCR is mainly used in the field of artificial intelligence, pattern recognition, and computer vision.

So how does it work? In simple words, for a computer, an image is nothing but a collection of pixels. In OCR processing, the image is scanned for light and dark areas to identify each character.  Continue reading OCR implementation in Android

Proxy Routing in Angular 4 Applications

This blog intends to deal and simplify routing in Angular 4 applications in both development and production environment. While working on routing in Angular 4 applications, we often face some of the following challenges:

  • Finding a solution to the problem of cross-origin issues in Angular development environment
  • Separating routing configurations and APIs servers URLs from the code, making the application more robust and maintainable
  • Finding a generic solution where frequent changing of API URLs (due to deployment on different servers, let’s say for the purpose of load balancing) do not force you to modify and change the code
  • Servers where the APIs deployed do not appear in your code at all

Continue reading Proxy Routing in Angular 4 Applications

Firebase cloud messaging in iOS

Cloud messaging or push notification is one of those “topics” that gets left out. Primarily because we are too busy beautifying the app, or working on a new feature, or we think it isn’t a big deal. Push notifications are as big a deal as any. Whether you want to re-engage your users, or deliver personalised content, or display targeted advertisements, push notification is the way to go. Continue reading Firebase cloud messaging in iOS

Go ServerLess with Firebase cloud functions

Firebase Cloud function

With announcement of cloud functions beta at Google cloud next 2017 event, Google has added one of the highly requested features in the firebase suite. This is one major step from Google in making firebase serverless. In this post, we will see some of the capabilities, pros and cons, setup and deployment of firebase cloud functions. Google IO is just days away and knowing about firebase is surely going to help in understanding the upcoming firebase features. Continue reading Go ServerLess with Firebase cloud functions