I'm using two targets, one for our production app and one for our staging app, and I added STAGE
to both Debug and Release in Active Compilation Conditions for the Stage target in order to change API calls from our production backend to our testing backend. It all works when debugging, on both real devices and on the simulators, but when I upload the app so our internal testers can try the app in Testflight, they get the API calls from the production. What have I missed?
It seems like the flag doesn't work when I archive the Stage target. I have only added Active Compilation Conditions to the Stage target, just like the image below shows, and I'm using the following code to change the API variables:
#if STAGE
// setting up stage variables
...
#else
// setting up production variables
...
#endif
EDIT: Seems like I hadn't understood how to do this. I didn't need two targets, just setting up different schemes. By doing that, I could easily add custom flags based on the scheme, instead of setting up different targets.
More reading: https://medium.com/@pablosanchezdev/managing-different-environments-and-configurations-in-xcode-for-ios-projects-6c70d46e1b22