title: iOS - How to determine if app was built as Debug or Release
body: <p>Yes, I know that this question has already been asked and answered three times here at Stack Overflow. </p>
  
  <p><a href="https://stackoverflow.com/questions/9063100/xcode-ios-how-to-determine-whether-code-is-running-in-debug-release-build">Xcode / iOS: How to determine whether code is running in DEBUG / RELEASE build?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/19451944/checking-if-the-app-is-build-as-release">Checking if the app is build as release</a></p>
  
  <p><a href="https://stackoverflow.com/questions/19420832/how-can-know-debug-or-release-in-ios-app">How can know Debug or Release in iOS App?</a></p>
  
  <p>But I have two problems with all of these answers. </p>
  
  <p>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.)</p>
  
  <p>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.</p>
  
  <p>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:
  <a href="https://stackoverflow.com/questions/7085644/how-to-check-if-apk-is-signed-or-debug-build">How to check if APK is signed or &quot;debug build&quot;?</a>  </p>
  
  <p>So I'm wondering if some similar technique exists for iOS apps. Preferably something that can be done from Swift.</p>