This is actually quite easy.
#if DEBUG
let pushEnvironment = "development"
#else
let pushEnvironment = "production"
#endif
This would work in most circumstances and with common Xcode project setups, as by default Xcode sets the aps-environment
entitlement to development
or production
based on whether it is built for debugging or release.
Unfortunately this is not foolproof, as there could be scripts that change the entitlement with a build script, and so on. If you know your builds are simple, then this would work. But it is definitely not a foolproof approach.
The entitlements are built into your signed app and don't exist in a recognizable form, so it is not possible to read them while running. You could possibly use some creative build script engineering to read the aps-environment
entry from the file, but with so many variables that goes into anything but the simplest build configurations, this would also be fragile.
So, if this is for your own project (as in, you're not building a library for general use that will answer this question), and you know no build shenanigans are going on the #if DEBUG
construct might be the easiest solution.