- Home /
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: http://docs.unity3d.com/Manual/PlatformDependentCompilation.html
"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
Answer by p_025 · Mar 20, 2016 at 05:08 AM
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.
Answer by OndrejP · Jan 20, 2020 at 03:18 PM
I'm using this
#if DEVELOPMENT_BUILD || UNITY_EDITOR
Debug.Log("Some logging");
#endif
Answer by RMGK · Jul 30, 2019 at 11:05 PM
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
Answer by roointan · Mar 28, 2020 at 06:55 AM
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.
Your answer
Follow this Question
Related Questions
Is it possible to hide the Development Build stamp while still including debug symbols? 0 Answers
Build Settings or Project descriptor file in Unity 1 Answer
Build Settings Error 0 Answers
Input.accelerometer x,y,z always returning zero 1 Answer
Simple UI not appearing once deployed to iOS (4.6.2) 1 Answer