Search code examples
c#iosunity-game-enginestatic-linkingdynamic-linking

Why does iOS link "static" to Unity?


[DllImport("__Internal")]
private static extern void IOSFBInit(string appId, bool frictionlessRequests, string urlSuffix, string unityUserAgentSuffix);  

First, sorry for my English.
I already know that iOS use DllImport("__Internal") for "static link" to C# script(Unity).
But, other platforms(Android, Windows..) are using dynamic linking not static linking.
Why "only" iOS use static linking to link C# script?


Solution

  • That is a limit on iOS now. Because the library's signature and app's signature must be the same. But Apple had provided a function of dynamiclly load on macOS.

    There is a instance in UnityWebRTCPlugin.

    • for iOS use libwebrtc.a
    • for macOS use libwebrtc.dylib

    This is a brief description about statically load and dynamiclly load.