Product > Scheme > Edit Scheme > click Duplicate Scheme
This basically creates a new env configuration, so I named the new one Vibee Staging. Then I duplicated it again, and named the third one Vibee Production.
To add environment variables, choose edit scheme again, and:
-
In the edit dialpg that launches, click
Run
on the left pane, then theInfo
tab. If you're in a development configuration, theBuild COnfiguration
should be set toDebug
. If in a staging or production scheme, this should be set toRelease
. -
Stay in the
Run
section, but go to theArguments
tab. In the environment variables section, click the plus to add some.
(Make sure to add any variables you create to all the other schemes that you've created as well)
You can access them via ProcessInfo
API:
let PROCESS_ENV = ProcessInfo.processInfo.environment
let BASEURL = PROCESS_ENV["API_BASE_URL"]!
Whatever scheme is selected when you run or archive the project, those env variables will be available at runtime.
You can switch between the environments like this.