When working with IL2CPP builds, you may encounter an error when calling a UnityEngine method, such as the UnityEngine.Transform method "LookAt":

api.CallMethod("//*[@name='LeftHand']/fn:component('UnityEngine.Transform')", "LookAt", new Vector3[] { target });

This can fail with the error:

Unable to find method: LookAt in object: //*[@name='LeftHand']/fn:component('UnityEngine.Transform')
UnityEngine.Logger:Log(LogType, Object)
gdio_unity_agent.MessageHandlers.Cmd_CallMethod:Process(GDIOAgent, ProtocolMessage)
System.Reflection.MemberFilter:Invoke(MemberInfo, Object)

This may happen even if the method seems like something that should be included in the build by default. However, this results from the IL2CPP compiler stripping out any code not explicitly used.

To work around this issue, you can simply add a call to the specific command signature to the GDIO/IL2CPP/GDIOStub.cs file prior to compilation. For example, the line below will address the error above.

(new GameObject()).transform.LookAt(new Vector3(0,0,0));

If you need to include additional methods or an entire class, you would add an entry for that class to the /GDIO/Resources/link.xml file. In this example, we would add the UnityEngine.Transform class as follows:

<assembly fullname="UnityEngine.CoreModule">
  <type fullname="UnityEngine.Transform" preserve="all" />

A similar approach can be used for any "Unable to find method" error where the method call has been verified to work in the Editor and Mono builds.