Thursday, 30 August 2018

Multiple Target XCode

Hello Friends

If you developed an App and you want to create different different settings of app like Local, Dev, Prod environments server url change or multiple app developed with same code with minor changes at that time Multiple Target is use full.

How to create multiple target?

- Select project in navigator and select target

creating new target from xcode app

- Now selecting target and create duplicate target 

- Now rename the target (Target Copy -> TargetPROD)

duplicate target create in xcode

- Then Go To Scheme and select Mange Schemes

- Then Double tap to rename Target name (Target copy -> TargetPROD)

Rename target from project schemes

- Now Target created.
- Now based on target we set preprocessor in Build Settings -> Other Swift Flags

- > Target -> -D DEV
- > TargetPROD -> -D PROD

Other swift flag change from build settings in xcode

- Now add this code and change both target and run

import UIKit

#if DEV
    let baseURL = "Dev base url"
    let baseURL = "Prod base url"

class ViewController: UIViewController {

    override func viewDidLoad() {


In Target => Print "Dev base url"
In TargetPROD => Print "Prod base url"

You can change also Info.plist, File, bundle settings etc.

You can also watch video 

If you have any query then comment.

Thank you.

No comments:

Post a Comment