"[DllImport("__Internal")]" - what does the "__Internal" mean?
Asked Answered
C

2

12

I am working with unity for an iOS game. For unlocking achievement I need to access a "Achievement.mm" file from my c# code:

    [DllImport("__Internal")]
    private static extern void
       GKAchievement(string achievementID, float progress, bool value);

I got this code from a forum. But, what does the "__Internal" means ?

Corrientes answered 26/7, 2016 at 8:8 Comment(4)
Related : #15644049Laser
It is specific to Mono, tells it to look for the function in your own program instead of another DLL. I think also required to get your app certified by Apple. Explained pretty well in the docs.Furtek
This is a great question!Coppage
That's certainly a handy link, @HansPassant !Coppage
B
11
  • Plugins link their code to C# unity using [DllImport()].
  • __internal is a keyword used for static linking needed by specific platforms, such as XBox and iOS.
  • Other platforms usually use dynamic linking, hence this is not needed.

Please for more info refer to: https://docs.unity3d.com/Manual/NativePlugins.html

Brumaire answered 23/10, 2017 at 14:3 Comment(2)
Updated, sorry about that.Brumaire
Updated again :)Brumaire
M
6

Just the minor tip.

If the library being loaded is __Internal, then the main program is searched for method symbols. This happens to be the case on iOS platform.

The plugins on iOS cannot load dynamically. Only statically as @RaxelZ explained.

It is different for OSX, Windows, Android ... those platforms may load plugins dynamically. For iOS, only statically.

Massa answered 1/6, 2018 at 19:45 Comment(2)
What do you mean by "load statically" and "load dynamically"?Mandragora
"statically" means it's linked with the main program as if it's part of the program code. "dynamically" means it's linked and the main program has a collection of unresolved references to functions that it expects will be supplied at runtime, normally via an external DLL. That DLL can be swapped out after the main program is linked, but static libraries cannot be swapped out, they're baked into the binary. Long winded but I hope that helps.Hedwighedwiga

© 2022 - 2024 — McMap. All rights reserved.