Hot Restart available in Uno Platform

With the release of Visual Studio 16.5 Preview 2, Microsoft and the Xamarin.iOS team released a preview of the Hot Restart feature.

This provides a way for Xamarin developers to create and debug Xamarin.iOS applications using a physical device using only a Windows machine, where a mac used to be required. This makes the developer loop a lot shorter when deploying on a device.

As a reminder, Uno Platform relies on Xamarin ‘classic’ (see architecture diagram and how Uno works) to deliver your UWP/WinUI apps to mobile – iOS and Android. Therefore, any advancement in Xamarin.Android or Xamarin.iOS can be easily inherited by Uno as well.

With some simple modifications, it’s possible to develop an Uno Platform app on iOS, using both Xamarin.iOS hot restart and Uno Platform XAML Hot Reload.

To use this feature in your app, all you’ll need is to modify your main.cs file in the iOS project head to look like the following:

 

public class Application 
{ 
  // This is the main entry point of the application. 
  static void Main(string[args) 
  { 
    // if you want to use a different Application Delegate class from "AppDelegate" 
    // you can specify it here. 
    UIApplication.Main(args, null, typeof(App)); 
  } 
} 
 
#if DEBUG 
public class HotRestartDelegate : Xamarin.Forms.Platform.iOS.FormsApplicationDelegate 
{ 
  public override bool FinishedLaunching(UIApplication uiApplicationNSDictionary launchOptions) 
  { 
    Windows.UI.Xaml.Application.Start(_ => new App()); 
    return base.FinishedLaunching(uiApplicationlaunchOptions); 
  } 
} 
#endif

 

 

You’ll also need to install the Xamarin.Forms nuget package for the added class to run properly. Head to the Microsoft docs on Xamarin Hot Restart to get started!

 

In Closing

If you are new to the Uno Platform, you may want to run through the Getting Started tutorial. This will ensure you have the correct environment set up and that you have the latest release of Uno. If you have already worked with Uno, you may want to update your Uno package via your Visual Studio NuGet package manager.

 

 

 

 

 

Share this post:
We’re excited for you to join us very soon for UnoConf 2021Register Today to Save Your Spot