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.
Have you tried including your types in the linker defiitions in link.xml?
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.
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.
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?
I guess Unity assumes if the DLL is not needed the user will not add it into the project.
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?
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.