DEVELOPMENT_BUILD define never set

I would like to compile-out a lot of C# test code in the release version of my game. I don’t wan’t to have to remember to change custom defines and I would like Unity Cloud Build to automatically do the right thing. I thought the best way was to use the “Development Build” checkbox in Build Settings. This is a test:

#if DEVELOPMENT_BUILD
	??? A
#else
	??? B
#endif

I expected this code to get a compilation error at ??? A when “Development Build” is checked but this never happens. What is wrong? Is there another way to solve my need?

Here is the documentation:

“You can also use the DEVELOPMENT_BUILD define to identify whether your script is running in a player which was built with the “Development Build” option enabled.”

I’m using Unity 4.6.9 on Mac OS X 10.11.1

I think the DEVELOPMENT_BUILD define only gets set/cleared when you actually do a build with the checkbox checked/cleared. Otherwise it will still be set to what it was the last time you did a build, regardless of the state of the checkbox.

This may be considered a bug. Consider reporting it to Unity.

Yea, just confirmed. DEVELOPMENT_BUILD only gets used in compiled builds. I’m not sure why Unity did that. To identify debug builds at runtime, use Debug.isDebugBuild or DEVELOPMENT_BUILD. In Editor use UnityEditor.EditorUserBuildSettings.development.
To solve your specific issue, I would use UnityEditor.EditorUserBuildSettings.development to set a define symbol in a cloud build preprocessor.

https://docs.unity3d.com/Manual/UnityCloudBuildPreAndPostExportMethods.html

I’m using this

#if DEVELOPMENT_BUILD || UNITY_EDITOR
Debug.Log("Some logging");
#endif

The documentation is clearly stating DEVELOPMENT_BUILD is used for “player”, not “editor”.
This is not a bug I think, just a directive only to be used for builds.