Catching DLLImport errors

Hello,

I have a Android and a IOS C# wrapper I use to import my native libraries. I have set them up according to the plugin guides and it works fine.

However, due to the nature of unity I have to reference them both when I build, since I cannot load them at runtime with Reflection on android/IOS unless I manually copy them every time I build and thats not good. This means the C# wrapper for iOS also gets included in Android and vice versa, but I use Application.RuntimePlatform to determine which C# wrapper to use. So it works.

The problem is the declaration in the C# wrappers have to look like this:

  [DllImport("__Internal")]
  internal static extern void IOS_TestMe();

And if I build on Android, it will throw errors in my log for each and every DllImport used in the iOS wrapper.
Is there any way to suppress these errors? I can’t use try/catch since its in the class declaration.

If I understand your problem correctly, Platform Dependant Compilation might be what you need. It tells the compiler to completely ignore a block of code if its condition is not met, it would not get included in the build.