I have some dynamic values I need to change based on the type of build I am doing in Xcode.
I have created 2 schemes DEV
and PROD
and set environment variables in each
I then consume these in code as follows
var serviceDomain: String {
let envVar = ProcessInfo.processInfo.environment
guard let value = envVar["APP_SERVICE_DOMAIN"] else { fatalError("Missing APP_SERVICE_DOMAIN enviroment variable") }
return value
}
Is this the correct way to approach this?
Once an app is compiled, should these values now be bundled with it?
I have an issue in that once I've stopped my simulator, if I try to open an app built this way, it crashes and I suspect the environment variables aren't present anymore.
In short, I would like a build for dev that uses one set of variables and a build for release / production that uses another.