I've seen plenty of answers and am familiar with using something preprocessor macros to check whether I'm in debug or release mode, but I'm keen to unit test around those scenarios, so I'd love a way to check that that I could mock.
Can we detect debug, ad hoc or release without using an #if defined?
You can have a key configuration in info.plist with value ${CONFIGURATION}. Make sure path for your plist file is set in you project build settings. See images below for reference.


You can then access infoDictionary to get the configuration. Code is below
let bundle : NSBundle = NSBundle.mainBundle()
let configuration : String = (bundle.infoDictionary!["configuration"] as! String) // configuration is key you set in plist file
configuration will be a string storing build configuration set in your scheme.
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