.NET iOS Runtime Limitations
Here’s some notes on the limitations imposed by IOS for Xamarin and MAUI applications.
These apply to both Xamarin and MAUI apps written for iOS.
Basically, the iOS kernel prevents any application from generating dynamic code at runtime.
So, any usage of JIT or other dynamic code generation will cause a runtime error in iOS.
For this, all code must be statically compiled ahead of time (AOT).
This may pose a challenge during development, because the Mono runtimes support some functionality, that may work on Windows or Android.
But, it may very well cause errors in iOS because all code is static compiled by the Xamarin.IOS compiler.
Here’s the list of disallowed dynamic code generation:
-
The System.Reflection.Emit is not available.
-
No support for System.Runtime.Remoting.
-
No support for creating types dynamically (no Type.GetType ("MyType`1")), although looking up existing types (Type.GetType ("System.String") for example, works just fine).
-
Reverse callbacks must be registered with the runtime at compile time.
The above are explained here: https://learn.microsoft.com/en-us/previous-versions/xamarin/ios/internals/limitations
How to Evaluate AOT Compatibility
This article includes steps to use Roslyn and AOT tooling to inspect your code and produce warnings if it’s not AOT compatible: https://devblogs.microsoft.com/dotnet/creating-aot-compatible-libraries/
No Comments