Plugin included in final binary even though it's not referenced

Hi,

I have a plugin in an Assets/Plugins folder. It’s enabled for iOS, and the plugin is a .NET DLL. I don’t reference any code from the plugin anywhere in my game. However, when I do a release build and archive I can still see that the plugin’s code has been built into the final binary. When I extract the IPA and look in the BCSymbolMaps I see IL2CPP symbols from the plugin’s code.

I would have expected that because no C# code made any references to the plugin that even if IL2CPP converted the plugin to C++ it would be optimised out at the linking stage. This doesn’t seem to have happened though.

Is this to be expected?

Thanks,
Sam

Ah, on inspecting the IL2CPPTypeDefinitions.cpp I can see a big table of all types, and it includes the plugin’s type.

So I guess the answer is yes - the plugin is included. This is really annoying. The plugin is my Hdg Remote Debug which is a debug tool, and I don’t want it to always be included in the final build. I only want it included when I’m actually using it (I suspect it is also causing System.Threading and some other DLLs to be pulled in).

I suppose I can disable the plugin for iOS in the “select platforms for plugin” list but then I have to do that whenever I make a build, and re-enable it when I want to use it for debugging.

Is there a way to exclude the plugin without having to manually enable and disable the platform checkbox?

You may be able to use my code as a starting point. I run this automatically on a script reload.

The reason I do this is because of this bug.

                var importers = PluginImporter.GetAllImporters();

                foreach(var importer in importers)
                {
                    if(importer.assetPath.StartsWith("Assets/Helpshift/Plugins/iOS/") && importer.assetPath.EndsWith(".bundle"))
                    {
                        if(!importer.GetCompatibleWithPlatform(BuildTarget.iOS))
                        {
                            importer.SetCompatibleWithPlatform(BuildTarget.iOS,true);
                        }
                    }
                }

Thanks so much! I’ll give that a try. I was attempting to rename the plugin folder in my build script but it was problematic. I figured there must be a way to set the plugin import settings programmatically but I my search-fu was failing me!

Actually I should point out that my post is incorrect. The bug I linked to is a bug with doing the actual code - Unity have confirmed. The reason I do the code is because in the Helpshift plugin the bundles have not been set to iOS, so it’s just a safety check.

No worries, this has still helped me! I was able to stop my plugin from being included. Thanks!