How to create a white label iOS app (Part 2)
Tags: ios, swift, xcode
Published: 2020-08-24 22:23:48

---
title: How to create a white label iOS app (Part 2)
published: true
date: 2020-08-24 22:06:26 UTC
tags: ios,swift,xcode
canonical_url: https://www.rockandnull.com/how-to-create-a-white-label-ios-app-part-2/
---

 ![How to create a white label iOS app (Part 2)](https://images.unsplash.com/photo-1494537176433-7a3c4ef2046f?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=2000&fit=max&ixid=eyJhcHBfaWQiOjExNzczfQ)

[How to create a white label iOS app (Part 1)](https://www.rockandnull.com/how-to-create-a-white-label-ios-app/).

On Part 1 we talked about **Targets** and how to use them in a white label product, but we noticed a rising problem. We couldn't differentiate (easily) the **.plist** files for each target. So, we need to create a **structure** to keep the non-shared files for each target.

You can download the project [here](https://github.com/Rock-and-Null/iOS---WhiteLabel/releases/tag/Part2).

First, we will create a folder called **Resources** and then two subfolders called **RealCoffee** and **TestCoffee** (physical folders using **New Group** option), and then we will place each **.plist** under its corresponding target.

Note: There is an extra **.plist** file called **TestCoffee copy-Info.plist**. Please delete it.

Our project directory should look like this:

![How to create a white label iOS app (Part 2)](https://www.rockandnull.com/content/images/2020/08/Screenshot-2020-08-24-at-7.44.59-PM.png)

If you try to build and run the project you will notice that the Xcode is complaining about the Info.plist file. Since we renamed our Info.plist files, Xcode doesn't know where to find them so we need to set the path to the files. We will do that in **Build Settings->Info.plist file.** Just make sure to use the absolute value of the path. For RealCoffee is **RealCoffee-Info.plist** and for TestCoffee is **$(SRCROOT)/TestCoffee/Resources/TestCoffee/TestCoffee-Info.plist.** The reason is that the 2 files are located in different paths. We left it that way to demonstrate the difference.

<iframe width="100%" height="386" scrolling="no" border="no" allowtransparency="true" frameborder="0" style="border:none!important;width:100%!important;height:386px;position:relative;" src="https://upscri.be/ltv52r?as_embed=true"></iframe>

Our structure is fairly easy to understand. Any file that is bound only to one of the targets, it should fall under the target's folder. To illustrate, click on RealCoffee folder and create an object called **Coffee** and set the target only to RealCoffee. Then, repeat the procedure for TestCoffee and set the target only to TestCoffee.

![How to create a white label iOS app (Part 2)](https://www.rockandnull.com/content/images/2020/08/Screenshot-2020-08-25-at-12.50.33-AM.png)<figcaption>Two Coffee files with different target membership</figcaption>

We will create 2 Coffee classes with different implementation in order to demonstrate how the targets interact with the files.

```
class Coffee {
    static func coffeeDescription() -> String {
        return "TestCoffee"
    }
}
```
<figcaption>Coffee class for TestCoffee</figcaption>

```
class Coffee {
    static func coffeeDescription() -> String {
        return "RealCoffee"
    }
}
```
<figcaption>Coffee class for RealCoffee</figcaption>

Now let us update the coffeeIBAction to call the Coffee static function:

```
    @IBAction func coffeeIBAction(_ sender: Any) {
        let appName = Bundle.main.infoDictionary?["CFBundleName"] as? String
        let appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
        self.popUpOptionDialog("",content: "You have ordered coffee using the \(appName!) app with version \(appVersion!) and coffee description: \(Coffee.coffeeDescription())")
    }
```
<figcaption>Alert view in ViewController</figcaption>

Now, if you run the app you will notice that the result for **coffeeDescription()** is different for each target.

We have used this example because it's easy to understand the fundamentals, but it's not recommended to create the same class with different target membership. There is a better way and we will demonstrate it in the next part!

Happy coding!
[Original Article](https://www.rockandnull.com/how-to-create-a-white-label-ios-app-part-2/).

[How to create a white label iOS app (Part 1)](https://www.rockandnull.com/how-to-create-a-white-label-ios-app/)
[How to create a white label iOS app (Part 2)](https://www.rockandnull.com/how-to-create-a-white-label-ios-app-part-2/)
[How to create a white label iOS app (Part 3)](https://www.rockandnull.com/how-to-create-a-white-label-ios-app-part-3/)
[How to create a white label iOS app (Part 4)](https://www.rockandnull.com/how-to-create-a-white-label-ios-app-part-4/)
[How to create a white label iOS app (Part 5)](https://www.rockandnull.com/how-to-create-a-white-label-ios-app-part-5/)