- Home /
System.Reflection on iOS in Unity 3
Is System.Reflection available on iOS with Unity 3? and if it is, are there any quirks?
Answer by Alex-Chouls · Jan 27, 2011 at 05:04 PM
I've been using System.Reflection on iOS with Playmaker and haven't run across any issues.
I remember reading that Emit doesn't work on iOS.
http://docs.xamarin.com/ios/about/limitations#System.Reflection.Emit "Important: Do not confuse Reflection.Emit with Reflection. Reflection.Emit is about generating code dynamically and have that code JITed and compiled to native code. Due to the limitations on the iPhone (no JIT compilation) this is not supported.
But the entire Reflection API, including Type.GetType ("someClass"), listing methods, listing properties, fetching attributes and values works just fine."
Answer by Paul Ash · Feb 17, 2011 at 06:05 PM
I've been running into problems with it. Where the iPhone crashes when trying to do Assembly.Load
Assembly load will not work, iOS is AOT compiled not JIT. Also dynamic code adding is forbidden on iOS (and can get your app black listed and your dev account banned if you try to circumvent it), you would have to add scripting if you want to do such a thing, so it uses the same compiled code base all the time
Also be careful. If you use code-stripping to reduce the filesize Unity could strip things away you might want to access via reflection. Since reflection is dynamic, Unity can't deter$$anonymous$$e that at compile / build time.
In most cases if you use at least each classname somewhere in a included script there should be no problem, but in some rare cases you could shoot yourself in the foot
Or simply look at the documentation, understand what link.xml is for and you are normally safe too :)