Handle multiple environment using multiple target and macro

suggest change

For example, we have two environments: CI - Staging and want to add some customizations for each environment. Here I will try to customize server URL, app name.

First, we create two targets for 2 environments by duplicating the main target:

For each target, we will define a custom macro. Here I will define macro named “CI” in build settings of target CI, macro named “STAGING” for target Staging.

The development target (MultipleEnvironment target):

Target CI:

Target Staging:

Create scheme for each target:

We will create a header file to define SERVER URL as below:

It means,

If you want to do more customize, for example: Change app name for each target:

Almost done. Now we want to show current SERVER_URL to main screen:

Now, let’s see if we run the app with the default target (MultipleEnvironment)

CI target:

Staging target:

As you can see, value of SERVER_URL and app name is changed for each target :)

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Handle Multiple Environment using Macro:
* Handle multiple environment using multiple target and macro

Table Of Contents
12 UIView
15 UIColor
26 UIImage
28 CALayer
30 NSDate
40 iBeacon
49 NSTimer
79 NSURL
87 AWS SDK
96 NSData
101 Segues
104 EventKit
105 NSBundle
106 SiriKit
111 StoreKit
117 3D Touch
119 Keychain
120 Handle Multiple Environment using Macro
122 Block
141 AirDrop
144 UISlider
145 Carthage
146 HealthKit
151 plist
157 MVVM
164 UIPhoenix
166 Simulator
168 NSArray
169 OpenGL
175 Core Data
179 MyLayout
180 UIFont
189 Security
200 Codable