Yes, I know that this question has already been asked and answered three times here at Stack Overflow.
Xcode / iOS: How to determine whether code is running in DEBUG / RELEASE build?
Checking if the app is build as release
How can know Debug or Release in iOS App?
But I have two problems with all of these answers.
All of the answers, except the last answer to the third question, are based on testing preprocessor definitions at build time. I would prefer some technique that makes the determination at runtime, just to be completely sure there is no divergence between the preprocessor definitions and how the actual build ended up getting done. (OK, that's probably not possible.)
But another point is that I would prefer to have the code that makes the determination in a library module, but that the test is based on how the main app module was built. So if (by accident?) the library module is a Debug build but the main app module is a Release build, then I'd like the test to say the app is a Release build.
Maybe this doesn't make much sense (I'm totally new to iOS), but for my Android app this is possible - see the first answer here: How to check if APK is signed or "debug build"?
So I'm wondering if some similar technique exists for iOS apps. Preferably something that can be done from Swift.
You have the following entry in your Info.plist
file:
<key>Configuration</key>
<string>${CONFIGURATION}</string>
which you can access via:
var config = Bundle.main.infoDictionary?["Configuration"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With