Throw error at compile time on "release", but not on "debug" on certain conditions

I want to implement in my code “fatalError()” as per this article: https://cocoacasts.com/what-is-fatalerror-in-swift-and-whe…/.

I would like to know if there is a way when you run your code on “release” instead of “debug”, XCode gives you an error that you have “fatalError()” function in your code. “fatalError()” is just an example. I may want to give me the same error if I forgot to take out some random UIAlertController or something else that was meant just for development and testing.

So, some customizable solution to not let me build in release if I have *blank* in my code.

Thank you!

You can use #if like this:


#if DEBUG

… code that should be compiled when debugging …

#else

… code that should be compiled otherwise …

#endif


The DEBUG symbol is declared by default in the build settings when you create a project. You could use this to declare a "myFatalError" function in the DEBUG case, but not otherwise, and use it in place of "fatalError". That would give a compilation error if you didn't take out references to it before building a release build.

Throw error at compile time on "release", but not on "debug" on certain conditions
 
 
Q