Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Failed to load AOT module (when no DLL calls made and stripping on)

Discussion in 'iOS and tvOS' started by andymads, Aug 11, 2014.

  1. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    Just found something that might be a bug, or perhaps is 'just the way it works'?

    I have my own .NET DLL included in the project but if I don't actually make any calls to the methods in the DLL the app just quits on startup if the build has been made with stripping.

    The DLL is still loaded:

    Loading /var/mobile/Applications/49EE23A4-A106-40E5-ACB5-AB0008E08B66/misc.app/Data/Managed/DllTest.dll into Unity Child Domain

    Then I get this:

    Failed to load AOT module '/var/mobile/Applications/49EE23A4-A106-40E5-ACB5-AB0008E08B66/misc.app/Data/Managed/DllTest.dll.dylib' in aot-only mode.

    Then the app just quits.

    I noticed that the DllTest.dll.s file is missing from Libraries in Xcode.
     
  2. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
  3. Graham-Dunnett

    Graham-Dunnett

    Unity Technologies

    Joined:
    Jun 2, 2009
    Posts:
    4,287
    What Dustin said. If your script doesn't make any calls in the DLL, then the stripping feature will decide that all that tasty code isn't needed.
     
  4. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Just an FYI...I've actually seen classes get retained but actual properties get stripped when stripping is enabled as well, so it's definitely worth the link route rather than just trying to instantiate your class.
     
  5. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    Why doesn't Unity remove the DLL during the build as it's not needed?

    It seems to be the opposite of the Reflection problem where you need to use link.xml to stop code being removed. In this case I'm not using anything from the DLL so why does it load it?
     
  6. Graham-Dunnett

    Graham-Dunnett

    Unity Technologies

    Joined:
    Jun 2, 2009
    Posts:
    4,287
    I guess Unity assumes if the DLL is not needed the user will not add it into the project.
     
  7. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    Perhaps the user simply commented out some code that happened to use the DLL and then wondered why the build would not run.

    But seriously, surely the build process could be improved to handle this better?

    We've got 2 options:

    (1) Add to the linker file to maintain something that we're not even using at this time.
    (2) Delete and restore DLL as required.

    Is it worth posting this to the feedback section?
     
  8. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    option #2 should be your go-to. Why even have the DLL in your project if you're not using it? It's just unnecessary clutter.