Search Unity

Using IL2CPP in development

Discussion in 'Editor & General Support' started by tompave, Jul 8, 2018.

  1. tompave

    tompave

    Joined:
    Aug 28, 2017
    Posts:
    8
    Hello,

    I'm working with Unity 2018.1.7f and I'm looking for information on how to use IL2CPP in development.

    In this article it says that:
    Which makes sense, but the option to switch the scripting backend, in Edit > Project Settings > Player, seems to suggest that this is just for the standalone player used in the "builds".

    Screen Shot 2018-07-08 at 15.06.30.png

    I can't find anything specific about this in the docs, so my question is whether that setting also affects the development builds. To be clear, I'm referring to when I click the "play" button in the Unity Editor:

    Screen Shot 2018-07-08 at 15.09.42.png

    If it doesn't, where can I find more info on what that article means by "develop your project"? Is there any way at all to use IL2CPP when "playing" the game in the Editor?

    What would the recommended workflow be? Should I select IL2CPP, then build in "debug" mode, and launch the built artifact?
     
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,620
    No, the editor uses mono always.
     
    GameDeveloper1111 likes this.
  3. tompave

    tompave

    Joined:
    Aug 28, 2017
    Posts:
    8
    I see, thanks.

    Then what's the purpose of setting C++ Compiler Configuration to "Debug"? Is there a way to use breakpoints and locally debug a IL2CPP build?

    I've tried to search for some documentation on this, but I haven't found much.
     
  4. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,620
    If you build for iOS, the generated project is loaded in Xcode and compiled there. Thus, using a debug configuration allows you to debug the C++ generated inside Xcode. The same applies to XboxOne, where Visual Studio is used to build the generated C++ code, for example.

    Starting with Unity 2018.2, they also support to debug C# code with IL2CPP builds (on some platforms):
    https://forum.unity.com/threads/il2cpp-support-for-managed-code-debugging.533315/

    With "You should use IL2CPP to both develop and ship your Project" they mean if you build a player during development, such as a daily build for your QA, you should use the scripting backend you are going to use for the master build. The reason for this is Mono and IL2CPP often behave differently in some ways, they have different bugs and if you test your project only with Mono and then build your master with IL2CPP, you most likely run into issue that you could have caught during development already.
     
  5. tompave

    tompave

    Joined:
    Aug 28, 2017
    Posts:
    8
    Hi Peter77, thank you for the detailed answer.

    I feel that this kind of explanation should be in the official docs, because at the moment it's not very clear to beginners.
     
    Peter77 likes this.
  6. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    If you haven't done so yet, please check out the general IL2CPP docs here:

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

    You're correct though, we don't have much documentation for managed code debugging, either with Mono or IL2CPP. We're working to improve that now, so hopefully the docs for Unity 2018.2 will include this information.

    If you are looking specifically to debug the generated C++ code, check out this blog post, which does through an example:

    https://blogs.unity3d.com/2015/05/20/il2cpp-internals-debugging-tips-for-generated-code/

    We also did a talk about debugging generated C++ code:


    I hope this helps!
     
  7. tompave

    tompave

    Joined:
    Aug 28, 2017
    Posts:
    8
    Hi Josh, thanks.

    I had already read the docs, but the video and blog posts are definitely helpful.

    That's great to her, thanks!