When I use C# reflection in ios ,the deveice crashed with the info “Failed to load AOT module ‘MyAssembly’ while running in aot-only mode”.How can I solve this problem? Are there some other solutions for using dynamic scripts?
I’m waiting for your help,thanks very much.
There is a possibility to get it work. For example: If you use the WWWClass of Unity the receive a message from a server, there is a private var in WWW called responseHeadersString, that could not be accessed. But with Reflections you can do it. I have tested it on Windows, Mac, Android and iOS. Here is an example:
var rhsPropInfo = typeof(WWW).GetProperty("responseHeadersString",
System.Reflection.BindingFlags.Public |
System.Reflection.BindingFlags.NonPublic |
System.Reflection.BindingFlags.Instance);
if (rhsPropInfo != null)
{
#if !UNITY_IOS
var headersString = rhsPropInfo.GetValue(www, null) as string;
#else
//This is a workaround for getting Reflactions to work with iOS
var headersString = rhsPropInfo.GetGetMethod(true).Invoke(www, null);
#endif
string[] lines = headersString.ToString().Split(new string[] { "
", "
" }, StringSplitOptions.RemoveEmptyEntries);
foreach (var l in lines)
{
//Filter your string for what you want
}
I hope this will help
You can’t use that in iOS, since it’s AOT compiled, not JIT compiled.