A custom scripting define symbol configured in Unity Build Automation (UBA) did not propagate to the compilation phase for a build target, even though it worked locally. The issue occurred because the target's configuration was not using the same Build Profile as the local environment, so the define symbol was not applied. Linking the correct Build Profile asset in the target's configuration ensures defines are passed before compilation, and the expected code paths are executed.
Symptoms
- A scripting define symbol configured in the build settings of a target does not appear during compilation.
- Code that depends on the define behaves as if the symbol is not defined.
- The same define symbol works correctly in local builds when using a Build Profile.
Cause
Unity Build Automation (UBA) was not configured to use the same Build Profile as the local environment. Without explicitly specifying the Build Profile path, the cloud build falls back to default platform settings, which can ignore or override custom scripting define symbols set in the build target's configuration.
Resolution
- In the Unity Editor, confirm that the Build Profile includes the scripting define symbol.
- Locate the Build Profile asset (e.g., Assets/Settings/BuildProfiles/YourBuildProfile.asset).
- Commit that .asset file to source control and push it to the branch used by UBA.
- In the Unity Dashboard, go to DevOps → Build Automation → Configurations.
- Edit the target's build configuration.
- In the "Basic info" section, set the Build Profile path to the exact relative path of the asset (e.g.,
Assets/Settings/BuildProfiles/YourBuildProfile.asset). Do not use absolute paths. - Save the configuration and trigger a clean build so Unity runs with the -activeBuildProfile flag and applies the defines before compilation.
More Information
To learn more about build profiles, please check out our documentation for an introduction on the topic.