Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Is It Possible Checking buildable?

Discussion in 'Testing & Automation' started by su-juhyuklee, Aug 5, 2021.

  1. su-juhyuklee

    su-juhyuklee

    Joined:
    Jan 22, 2021
    Posts:
    4
    Hello!
    My team use Jenkins when build Ios / Android Platform.
    But when started build, often occurred build error.
    This is because the runtime code contains the editor code.
    I want to check this just like when building android; without UNITY_EDTIOR constants and editor asmdef codes, cannot using UnityEditor namespace
     
    Last edited: Aug 5, 2021
  2. crowejohn20

    crowejohn20

    Joined:
    Oct 5, 2012
    Posts:
    11
    Hey su-juhyuklee,

    Hard to understand what you are asking. I build a lot using Jenkins both iOS and Android. It seems you have an editor script included as part of your build process.

    You can mark your asmdef files, via the inspector, to include/exclude specific platforms/editor. It could be that this is your issue.

    As part of a build script, I think in the player settings, you can feed in any symlinks you have in the code to be picked up here as well.

    https://docs.unity3d.com/ScriptReference/PlayerSettings.SetScriptingDefineSymbolsForGroup.html

    Hope that helps.
     
  3. su-juhyuklee

    su-juhyuklee

    Joined:
    Jan 22, 2021
    Posts:
    4
    Thank's to reply

    The scenario I want to prevent is Like this

    asmdef name "B.Runtime" (platforms Check 'any platform')

    - To work somthing in unity editor, using editor method in B.Runtime
    - Normally to use edtior code in runtime code, programmers should wrapping #UNITY_EDITOR
    - But many programmers forget wrapping #UNITY_EDITOR. (obviously, Rider or visual studio not to say compile error)
    - And then programmer push that code
    - run build Android in Jenkins
    - Build error message like error CS0246: The type or namespace name 'FooEditorNamespace' could not be found (are you missing a using directive or an assembly reference?)

    Because Unity Android Build contain asset(obviously), to check buildable is too slow.
     
    Last edited: Aug 23, 2021
  4. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,649
    Unfortunately, there's no good way to do this today - you can turn on the 'No Engine References' checkbox for the asmdef, but this will prevent you from using both UnityEngine and UnityEditor APIs. We don't have a good way to let you keep using UnityEngine while blocking UnityEditor.

    The scripting team agree that the use case makes sense, they have added a task to their backlog to look into this.
     
  5. su-juhyuklee

    su-juhyuklee

    Joined:
    Jan 22, 2021
    Posts:
    4
    @superpig Any news?

    It's taking too long, so I'm trying to implement it,
    I am trying to implement the android/IOS build situation in the direction of modifying the csproj files. What should be deleted?
    as far as i can figure out
    - Read *.asmdef json and check whether it is runtime or editor, and delete the editor csproj file list from the sln file
    - Delete contents including 'EDITOR' in <DefineConstants> in each runtime csproj file
    - Delete <Reference Include="blabla.dll"> editor dlls in <ItemGroup> in each runtime csproj file

    I think it's like this, is it okay?
     
    Last edited: Nov 9, 2021