# Handle Multiple Environment using Macro
# Handle multiple environment using multiple target and macro
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): (opens new window)
Create scheme for each target: (opens new window)
We will create a header file to define SERVER URL as below:
- If we run/archive using the default target (MultipleEnvironment), the SERVER_URL is http://192.168.10.10:8080/ (opens new window)
- If we run/archive using CI target, the SERVER_URL is http://ci.api.example.com/ (opens new window)
- If we run/archive using STAGING target, the SERVER_URL is http://stg.api.example.com/ (opens new window)
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: (opens new window)
As you can see, value of SERVER_URL and app name is changed for each target 😃