Is it possible to write code in a Flex application that will only be run in a debug build, or when running through the debugger? Does Flex provide a way to actually remove code entirely from release builds, like C-style #defines?
The app is not necessarily running in a web page.
There are different way to check if the application is build using debug or release certificate, but the following way seems best to me. According to the info in Android documentation Signing Your Application, debug key contain following subject distinguished name: "CN=Android Debug,O=Android,C=US".
You can do conditional compilation like this:
CONFIG::debugging {
// this will be removed if CONFIG::debugging resolves to false at compile time
}
And then add this to the compiler flags:
-define+=CONFIG::debugging,true
for debug builds, and
-define+=CONFIG::debugging,false
for release builds. CONFIG
and debugging
can be anything, like MY_AWESOME_NAMESPACE
and fooBar
, it doesn't matter.
Read more here: Using conditional compilation.
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