I am trying to figure out how to handle variables/constants for different environments, e.g. development(or debug) and release. For instance when executing a unit test the url for a web service should point to the localhost, but in the final product it should point to the public api host.
I have read something about setting the Swift Compiler - Custom Flags Debug settings to -DDEBUG
and then in the code declare the variable like so:
#if DEBUG
let url = "http://localhost"
#else
let url = "https://api.example.com"
#endif
But that didn't work. When running a unit test the url is never set to http://localhost
. Did I miss something here?