March 26th, 2019

Introducing the Xamarin.iOS Interpreter

Chris Hamons
Principal Software Engineering Manager

Historically iOS applications have had a number of limitations when running on a device, as Apple disallows the execution of dynamically generated code. Applications are compiled “Ahead of Time” (AOT) before deployment because of this. You can read more about this architecture here.

“Ahead of Time” AOT

In most cases, AOT can provide performance benefits. It can also restrict a number of C# features from being used:

  • Assembly.Load and System.Reflection.Emit
  • Some uses of the C# dynamic feature

The team has been hard at work at overcoming these limitations while abiding by platform restrictions. The result is a new interpreter for Xamarin.iOS.

The Interpreter

Today we are promoting this experimental work into a preview ready for general testing.

The Interpreter, as the name implies, allows you to interpret at run time some C# parts of your application while compiling the rest ahead of time as usual.  Get started previewing by installing the packages below:

Visual Studio 2019: Xamarin.iOS Installer Visual Studio for Mac 8.0: Xamarin.iOS Installer

Once you have the preview installed (don’t forget your Mac build host), you can enable the interpreter by:

  • Opening the project’s options
  • Switch to iOS Build
  • Adding --interpreter to the Additional mtouch arguments.

We have some small samples available which show off some of the new functionality.

Known Issues

Try It Out!

Please take the new interpreter for a spin and provide feedback here: https://github.com/xamarin/xamarin-macios/issues/new

Topics
iOS

Author

Chris Hamons
Principal Software Engineering Manager

Principal software engineer at Microsoft (Azure SDK). Former principal software engineering manager at Xamarin.

5 comments

Discussion is closed. Login to edit/delete existing comments.

  • Jason Willett

    This extension can’t be installed as of VS 16.4.5: “Install Error : System.InvalidOperationException: Installation of Microsoft.VisualStudio.Android.DeviceManager failed. The extension has a lower version than required by Visual Studio. Please install the extension from Visual Studio Installer instead.”

  • Alvaro Rivoir

    Is this already in the stable channel?

  • Chris Timberlake

    For people wondering, This solves the MongoDB.BSON issue with AOT Compilation on iOS. It fixes the BSON Serialization, System.Reflection.Emit failures as well.

  • Homero Lara

    Wow, I didn’t realize MS was working on something like this. Looks extremely promising. 

  • Mike Simon

    Does this mean we’ll be able to use generics with functions like this:
    public async Task<T> Post(string url, object byteContent) {
        …
       return JsonConvert.DeserializeObject<T>(result); 
    }

    Going back to deserializing inside the calling function was painful 🙂