iOS JIT compile error on Generic method called with basic types (int, bool, float)

I have a generic method like this:

public class MyClass
	public T MyMethod<T>(string arg)
		return default(T);

When I try to call the method like this:

int someInt = MyClassInstance.MyMethod<int>("some_string");

I get the following error:

Attempting to JIT compile method 'MyClass.MyMethod<int> (string)' while running with --aot-only.

This also happens to bool and float types but it works for string.

Would you guys know why this happens? Thanks!

This happened because just-in-time (JIT) compilation does not work on iOS. All code must be ahead-of-time (AOT) compatible. default() sometimes uses JIT. When this happens, you will have to write the code in such a way to remove the use of default(). I can’t predict if it will or won’t.

I will update this answer if I figure out more.