Using RuntimeInitializeOnLoadMethod inside dll and using in iOS build
Hi all,
I created a simple script containing a method with [RuntimeInitializeOnLoadMethod]
and then packed this script into a dll.
After that I created an empty project, imported this dll and built it for Android and iOS. On Android everything worked fine (the method is called as expected), but on iOS the method doesn't seem to be called at all.
So the question is: Did I do something wrong or DLLs don't work on iOS?
I used Unity 2018.2.11f1 to pack the dll and for the empty project.
This is the script I packed into a dll:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TestInitializeOnLoad : MonoBehaviour {
[RuntimeInitializeOnLoadMethod]
static void OnRuntimeMethodLoaded()
{
Debug.Log("I'm initializing in runtime");
}
}
Answer by ivo-alves · Jul 12, 2019 at 01:30 PM
In case anyone is still having this issue you need force unity to include the lib because of managed code striping with: [assembly: AlwaysLinkAssembly] from UnityEngine.Scripting
https://docs.unity3d.com/ScriptReference/Scripting.AlwaysLinkAssemblyAttribute.html
Your answer
Follow this Question
Related Questions
How to reference external library/project 0 Answers
Placeholder dll with different dependency results in build-error on target platform (WSA) 0 Answers
CloudBuild - This device was signed for App Store and cannot be installed 1 Answer
Xcode stuck / hangs when compiling source files for Unity project 5 Answers